【问题标题】:Problem installing nodemon globally on macOS Mojave在 macOS Mojave 上全局安装 nodemon 时出现问题
【发布时间】:2020-12-18 22:10:03
【问题描述】:

在 Visual Studio Code 终端中,我发出以下命令:

npm install -g nodemon

终端的结果是:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/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!     /Users/ilkin/.npm/_logs/2020-08-30T16_39_29_236Z-debug.log

我该如何解决?

【问题讨论】:

    标签: javascript node.js json npm nodemon


    【解决方案1】:

    在安装前使用 sudo,它会要求输入凭据并完成

    sudo npm i - g nodemon
    

    【讨论】:

    • 首先谢谢。我使用 vs code 终端来安装 nodemon。我可以将 sudo 用于 vs code 终端吗?
    【解决方案2】:

    这意味着您没有 root 权限/不是超级用户。你有两种方法可以解决这个问题。

    • 在命令前使用sudo - 这通常会要求提供凭据并运行命令没有问题(希望如此)
    • 运行sudo -s 以在当前终端窗口中每次使用 sudo 自动运行命令(终端关闭后将停用)
    • 运行sudo su这将使计算机认为当前终端窗口已被root用户打开(一旦当前窗口关闭,将再次停用)

    【讨论】:

      猜你喜欢
      • 2020-02-28
      • 2019-03-27
      • 2019-05-20
      • 2021-04-12
      • 2018-08-04
      • 1970-01-01
      • 2021-08-05
      • 2021-12-23
      • 2019-08-13
      相关资源
      最近更新 更多