Search code examples
node.jsnpmenvironment-variablesnodemon

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...


Solution

  • 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.