简体   繁体   中英

Node.js: Why am I required to set my environment variables every time I want to run Nodemon?

For some reason, despite having:

C:\Users\name\AppData\Roaming\npm

in my environment variables (I double checked - it's in my User PATH variable), I'm unable to run nodemon directly without getting the standard 'nodemon' is not recognized as an internal or external command error.

When I installed nodemon, I ran the following:

> npm install -g nodemon

Currently, in order to use nodemon, I'm required to run the following:

> set PATH=%PATH%;C:\Users\name\AppData\Roaming\npm
> nodemon

After re-setting the path, I can run nodemon again - that is - until I close the command prompt, at which point I need to run "set PATH" all over again.

To re-iterate, the path is always there in my environment variables, so I have no idea why I need to set it each time...

Are you saying you checked the path inside your command window prior to setting the path? How do you launch the command window?

I solved my issue.

It turns out that there was a space directly before my npm user environment variable. For example, the PATH variable looked like this:

C:\path1;C:\path2; C:\Users\name\AppData\Roaming\npm

Note the space after the second path. After removing this space, everything worked correctly.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM