简体   繁体   English

在 macOS Mojave 上全局安装 nodemon 时出现问题

[英]Problem installing nodemon globally on macOS Mojave

In the Visual Studio Code terminal I issue to following command:在 Visual Studio Code 终端中,我发出以下命令:

npm install -g nodemon

The result in terminal is:终端的结果是:

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

How can I solve it?我该如何解决?

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

sudo npm i - g nodemon

This means that you do not have root privileges / are not a superuser.这意味着您没有 root 权限/不是超级用户。 You have two ways to solve this.你有两种方法来解决这个问题。

  • Use sudo before the command - this will usually then ask for credentials and run the command without a problem (hopefully)sudo之前使用sudo - 这通常会要求提供凭据并毫无问题地运行命令(希望如此)
  • Run sudo -s to automatically run commands with sudo every time in the current terminal window (will deactivate once the terminal has been closed)每次在当前终端窗口中运行sudo -s以使用 sudo 自动运行命令(终端关闭后将停用)
  • Run sudo su which will make the computer think that the current terminal window has been opened by a root user (again will deactivate once current window has been closed)运行sudo su这将使计算机认为当前终端窗口已被 root 用户打开(再次将在当前窗口关闭后停用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM