-bash: nodemon: command not found

Asked

Viewed 2,181 times

0

Hello, I wonder if you have someone with the same problem or something similar I ran this code sudo npm install nodemon and returned this to me

/Users/apple/.npm-global/bin/nodemon -> /Users/apple/.npm-global/lib/node_modules/nodemon/bin/nodemon.js

[email protected] postinstall /Users/apple/.npm-global/lib/node_modules/nodemon
node bin/postinstall || exit 0

Love nodemon? You can now support the project via the open collective
https://opencollective.com/nodemon/donate

[email protected]

Apparently, the nodemon was installed normally, but when I run the nodemon he appears -bash: nodemon: command not found

I don’t know what to do, I tried to put nodemon in the node_modules directory, I tried to put -g (globalmente), but nothing works

I’m on a Macbook Air 10.15.2 macOS Catalina

  • If you write node /Users/apple/.npm-global/lib/node_modules/nodemon/bin/nodemon he runs?

  • The nodemon only works with --save-dev, is in the page README and npmjs.org of them and if it is to install global it will be using sudo and with sudo npm i -g nodemon... still if it is global and did everything right and does not work then it is likely that no CLI package will work and that you are having trouble in your ~/.bashrc

2 answers

1

In linux you need to add npx before nodemon

npx nodemon app.js

Already in windows you don’t need to do this just use

nodemon app.js

Of course do not forget to install nodemon in the project, do not recommend global installation.

NPM

npm install nodemon --save-dev

Yarn

yarn add nodemon -D

1


I did a test using the High Sierra and it worked, I’ll describe what I did

I created a folder, and inside it, through the terminal, I typed:

npm init

To create package.json. Then I installed nodemon in this project as follows:

npm install --save-dev nodemon

I created an index.js file with a test schedule. I edited the package.json file and added the following to the "scripts part"

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon index.js"
}

After saving the change, by terminal, I ran the Node application as follows:

npm start

nodemon was run along with the test script.

  • Well, I couldn’t find the solution I wanted to my problem, but I found a way to circumvent, I put inside the package.json the variable serve execultural nodemon server.js and it worked and just put npm run serve which begins to rotate the nodemon, but from the looks of it startis a much better variable to put yourself, thank you very much

Browser other questions tagged

You are not signed in. Login or sign up in order to post.