npm install express-generator -g 错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”

时间:2021-05-10 13:20:46

标签: node.js

我正在关注 Mozila 网站上的 Express 教程教程。我做了以下几件事:

  1. 我安装了 Node-js

  2. 我使用 mkdir express_tutorial 创建导演“Express_tutorial”,并通过命令 cd Express_tutorial

  3. 我在里面执行了命令 npm init,并将他们询问的每个查询都保留为默认值。

  4. 我然后尝试了 npm install express 并在 package.json 文件中获得了一个快速依赖项。

  5. 然后我尝试了 npm install express-generator -g

然后我得到了以下内容:

npm install express-generator -g
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pc/.npm/_logs/2021-05-10T11_25_42_963Z-debug.log

0 个答案:

没有答案