在 macOS Mojave 上全局安装 nodemon 时出现问题
Problem installing nodemon globally on macOS Mojave
在 Visual Studio 代码终端中,我发出以下命令:
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
我该如何解决?
安装前使用 sudo,它会要求输入凭据并完成
sudo npm i - g nodemon
这意味着您没有root权限/不是超级用户。你有两种方法可以解决这个问题。
- 在命令前使用
sudo
- 这通常会询问凭据和 运行 命令没有问题(希望如此)
- 运行
sudo -s
每次在当前终端中使用 sudo 自动 运行 命令 window (一旦终端关闭就会停用)
- 运行
sudo su
这将使计算机认为当前终端 window 已被 root 用户打开(一旦当前 window 已被打开,将再次停用关闭)
在 Visual Studio 代码终端中,我发出以下命令:
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
我该如何解决?
安装前使用 sudo,它会要求输入凭据并完成
sudo npm i - g nodemon
这意味着您没有root权限/不是超级用户。你有两种方法可以解决这个问题。
- 在命令前使用
sudo
- 这通常会询问凭据和 运行 命令没有问题(希望如此) - 运行
sudo -s
每次在当前终端中使用 sudo 自动 运行 命令 window (一旦终端关闭就会停用) - 运行
sudo su
这将使计算机认为当前终端 window 已被 root 用户打开(一旦当前 window 已被打开,将再次停用关闭)