Currently I already install nodemon with command npm install -g nodemon
. And I got Permissions issue, so I do command with sudo npm install -g nodemon
and i did it. But when I make "nodeman" command was always show nodemon: command not found
.
If for any reasons you are unable to set a Global PATH then under your current project directory, run
npm install nodemon --save-dev
then under "scripts" in your package.json file, add "start": "nodemon app.js" like this -
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
}
then run
npm start
If you need to install nodemon globally on mac OS, try
sudo npm install -g nodemon
.
Then you'll have to enter your password. Once the installation is completed successfully, run
nodemon -v
to check nodemon version on terminal.
According to this , Create a new directory to store your global
packages. So that there is no permission issue.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Edit your .profile or .bash_profile to add the new location to your PATH:
export PATH=~/.npm-global/bin:$PATH
Then install the package without sudo
:
npm install -g nodemon
如果你想安装全局nodemon使用SUDO,因为如果你需要是全局用户,你需要是超级用户
The other answer is correct but my advice is that it's better to not install packages globally if you can help it, this makes your application self sufficient without relying on the environment and avoids versioning issues between applications.
npm install -D nodemon
You can now execute nodemon from scripts
in package.json:
"scripts": {
"start": "nodemon src/index.js"
}
Or you can execute it yourself using npx
if you're in that directory from the terminal. npx executes local scripts, eg npx nodemon --inspect ./src/index.js 8080
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.