【问题标题】:npm install not working. Says that I need to check permissions?npm 安装不工作。说我需要检查权限?
【发布时间】:2019-07-25 02:33:15
【问题描述】:

我现在正在尝试在我的机器上安装 eslint,但它说我需要检查权限,因为它缺少对 /user/local/lib/node_modules 的写访问权限。有谁知道如何解决这一问题?谢谢!

npm install -g eslint
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mkaplan/.npm/_logs/2019-03-03T18_05_46_487Z-debug.log

【问题讨论】:

  • 你用 sudo npm install -g eslint 试过了吗

标签: node.js npm


【解决方案1】:

试试sudo npm install -g eslint

【讨论】:

  • 感谢工作!应该猜到只是 sudo 它。
【解决方案2】:

对于 Linux 使用 sudo npm install 和 对于Window,以管理员身份运行powerShell并进入项目目录并运行npm install

【讨论】:

    【解决方案3】:

    在我的情况下,我在安装 angular 时遇到了同样的问题,所以只需将命令更改为:

    $ sudo npm install -g @angular/cli
    

    【讨论】:

      【解决方案4】:

      这样可以解决问题:

      sudo npm install -g npm
      

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      【解决方案5】:

      第一次尝试sudo npm install -g gatsby-cli 然后npm start

      【讨论】:

        【解决方案6】:

        使用这个npm install node-sass --save

        【讨论】:

          猜你喜欢
          • 2016-01-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-12-06
          • 2015-01-16
          • 1970-01-01
          • 2015-02-21
          • 1970-01-01
          相关资源
          最近更新 更多