When I run npm install -g <package>
it installs the packages in my user/AppData/Roaming/npm/npm_modules/ folder. This sub-folder is not in my PATH so if I try to run the package without explicitly calling the entire path the call fails with a '<package>' is not recognized as an internal or external command, operable program or batch file.
What can I do to fix this?
Thanks
Path of Global Packages in the system: Global modules are installed in the standard system in root location in system directory /usr/local/lib/node_modules project directory. Command to print the location on your system where all the global modules are installed.
Globally installed npm packages location On macOS computers, npm will be installed under /usr/local/bin/npm soft link path. The actual path to the npm package is under /usr/local/lib/node_modules . Any globally installed packages will end up in that path as well.
Global installs on Unix systems go to {prefix}/lib/node_modules . Global installs on Windows go to {prefix}/node_modules (that is, no lib folder.)
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package. By default, npm install will install all modules listed as dependencies in package. What is installing globally and locally?
On Windows computers, global NPM packages should be installed under the roaming/ folder. Like in Unix-based systems, you can use the npm list -g command to find your global node_modules/ folder location: Now you’ve learned how to find where NPM packages are installed globally.
These are typical npm paths if you install a package globally: Just press windows button and type %APPDATA% and type enter. Above is the location where you can find \npm\node_modules folder. This is where global modules sit in your system.
The directory needs to be on the path, so use setx .. /M to set the system path (under HKEY_LOCAL_MACHINE). This is what requires you to run this in a shell with administrator permissions. Tell npm to use this new path.
I'm using win8.1 and I found that the nodejs installer didn't add the path to global node modules to the system PATH. Just add %AppData%\npm;
to the user variable(since %AppData% dir is depending on user) PATH
to fix it.
You will need to log out then log back in for the change to your PATH variable to take effect.
SET PATH=%AppData%\npm;%PATH%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With