How to install nodemon Nodejs on macOS? nodemon keeping show : command not found
Asked Answered
P

6

16

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.

Pact answered 20/6, 2019 at 13:54 Comment(1)
Try export PATH=$PATH:~/npmWorry
I
22

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
Illiberal answered 20/6, 2019 at 14:18 Comment(3)
Thank u it's work for me. But I still wonder, why i've to add this "start": "nodemon app.js" on my package.json?Pact
With that written, you'll be able to run "npm run start" and then the mapped script ( which is "nodemon app.js" will run).Herries
Note: npm adds ./node_modules/bin to the working path, so that scripts will be able to use executable scripts installed to the local node modules... I actually have that added to my path statement as-is, so that I can use local node module bin scripts without issue.Gallstone
V
14

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.

Volumed answered 19/7, 2020 at 15:38 Comment(0)
T
6

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
Translatable answered 20/6, 2019 at 14:5 Comment(1)
Thanks - this worked a treat and feels organised in handling global packages :praying-hands:Maurilia
F
2

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

Frogman answered 28/8, 2019 at 4:15 Comment(0)
T
0

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

Trihedron answered 20/6, 2019 at 14:17 Comment(0)
F
0

Just run these commands and the error will get solved. Specially for MAC People:

  1. sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

  2. Enter your laptop password

  3. npm install i -g nodemon or npm install -g nodemon

All set .....🎉

Felixfeliza answered 15/2, 2023 at 4:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.