从终端安装 nodemon 时出错?我实际上在更新 Nodejs 时也遇到了同样的问题

Error while installing nodemon from terminal ? I actually had the same problem while updating Nodejs too

这是抛出的错误,我在更新 Nodejs 时遇到了同样的问题,但是,我设法使用下载选项对其进行了更新。但每次我尝试从终端安装 nodemon 时仍然有这个

JuJu:/ juri$ 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/juri/.npm/_logs/2020-06-21T11_25_30_937Z-debug.log
JuJu:/ juri$ 

Try using nvm to reinstall node. 对我有用。

安装 nvm: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

检查是否安装: command -v nvm

安装节点: nvm install nodenvm install <SPECIFIC_NODE_VERSION>

希望对您有所帮助!

要解决此问题,请更改文件夹的所有者。 运行 这个命令:

sudo chown -R $USER /usr/local/lib/node_modules

或者您可以使用

sudo npm install -g nodemon

如果你是 sudoer..