How to install nodemon globally?

Asked

Viewed 2,538 times

0

I’m trying to install the nodemon globally, using:

npm install nodemon --global

It seems to install normally, with two warnings for an optional module:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0

But when I try to execute him:

nodemon servidor.js

Makes a mistake:

'nodemon' is not recognized as an internal or external command,
operable program or batch file.

What’s wrong with it?

P.S. on another computer worked smoothly. I’m on a Windows 10.

  • Did you install with one user and now are with another? What operating system do you use? For example if you do install -g nodemon as sudo it installs in a board that is not common to other users.

3 answers

3


In some facilities of Node, the prefix is not assigned in the way of the environment variables, then what you install globally does not work as expected. To resolve this, we have to add the prefix in the way of the environment variables. This can be done by command prompt.

To do this, first it is necessary to find out which is the prefix path, this can be solved by doing so:

npm config get prefix

The command will result in a path, copy it and paste in the next command:

set PATH=%PATH%;caminho;

Demonstration

inserir a descrição da imagem aqui

1

To complement the @Luc response, in Windows 10, the above configuration did not persist - and I decided to manually put in Path of variáveis de usuário (not in the system):

variáveis de usuário; path selecionado

In the Path, i included the address %USERPROFILE%\AppData\Roaming\npm:

inserir a descrição da imagem aqui

And after a reboot, finally the configuration persisted.

-1

You must run with the following command:

npm nodemon servidor.js

Browser other questions tagged

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