简体   繁体   English

我无法在npm nodejs中安装nodemon

[英]i cannot install nodemon in npm nodejs

i can not install nodemon it has problem with npm 我无法安装nodemon,npm有问题

Vus-MacBook-Air:nodejs vuvantuu$ sudo npm install -g nodemon Vus-MacBook-Air:nodejs vuvantuu $ sudo npm install -g nodemon
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/nodemon npm WARN checkPermissions缺少对/ usr / local / lib / node_modules / nodemon的写入权限
npm ERR! npm ERR! path /usr/local/lib/node_modules/nodemon 路径/ usr / local / lib / node_modules / nodemon
npm ERR! npm ERR! code ENOENT 代码ENOENT
npm ERR! npm ERR! errno -2 埃尔诺-2
npm ERR! npm ERR! syscall access 系统调用访问
npm ERR! npm ERR! enoent ENOENT: no such file or directory, access '/usr/local/lib/node_modules/nodemon' enoent ENOENT:没有这样的文件或目录,访问'/ usr / local / lib / node_modules / nodemon'
npm ERR! npm ERR! enoent This is related to npm not being able to find a file. enoent这与npm无法找到文件有关。
npm ERR! npm ERR! enoent 天生的

npm ERR! npm ERR! A complete log of this run can be found in: 可以在以下位置找到此运行的完整日志:
npm ERR! npm ERR! /Users/vuvantuu/.npm/_logs/2019-08-08T07_07_43_043Z-debug.log /Users/vuvantuu/.npm/_logs/2019-08-08T07_07_43_043Z-debug.log

You must be required administrative privileges to install anything, you can use 您必须具有管理权限才能安装任何内容,您可以使用

sudo npm install -g nodemon 须藤npm install -g nodemon

As the error says - you don't have write access to the /usr/local/lib/node_modules folder. 如错误所述-您没有对/usr/local/lib/node_modules文件夹的写访问权。

The simplest way to get rid of this error - is to run the command via sudo 消除此错误的最简单方法-通过sudo运行命令

sudo npm i -g nodemon


But if you don't want to run it via root user for any reasons (eg security) you could install packages globally for a given user. 但是,如果出于任何原因(例如安全性)不想通过root用户运行它,则可以为给定用户全局安装软件包。

  1. Create a directory for global packages 为全局软件包创建目录
mkdir "${HOME}/.npm-packages"
  1. Tell npm where to store globally installed packages 告诉npm在哪里存储全局安装的软件包
npm config set prefix "${HOME}/.npm-packages"
  1. Ensure npm will find installed binaries and man pages 确保npm将找到已安装的二进制文件和手册页

Add the following to your .bashrc / .zshrc : 将以下内容添加到您的.bashrc / .zshrc

NPM_PACKAGES="${HOME}/.npm-packages"

export PATH="$NPM_PACKAGES/bin:$PATH"

# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

NOTE: If you are running macOS, the .bashrc file may not yet exist, and the terminal will be obtaining its environment parameters from another file, such as .profile or .bash_profile . 注意:如果您正在运行macOS,则.bashrc文件可能尚不存在,并且终端将从其他文件(如.profile.bash_profile获取其环境参数。 These files also reside in the user's home folder. 这些文件也位于用户的主文件夹中。 In this case, simply adding the following line to them will instruct Terminal to also load the .bashrc file: 在这种情况下,只需向它们添加以下行即可指示终端也加载.bashrc文件:

source ~/.bashrc

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

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