首页 > 解决方案 > npm install express-generator -g 错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”

问题描述

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

  1. 我安装了 Node-js

  2. 我使用命令创建了一个导演“Express_tutorial”mkdir 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

标签: node.js

解决方案


推荐阅读