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
If you want to install global nodemon use SUDO, because if you need to be a global user, you need to be a super user
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, e.g. npx nodemon --inspect ./src/index.js 8080
Just run these commands and the error will get solved. Specially for MAC People:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Enter your laptop password
npm install i -g nodemon or npm install -g nodemon
All set .....🎉
© 2022 - 2024 — McMap. All rights reserved.
export PATH=$PATH:~/npm
– Worry