Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global NPM package installed but command not found

I have globally installed two npm packages "download" and "enigmavirtualbox" via command line:

npm install -g download and npm install -g engimavirtualbox

I'm trying to use them in a batch file to bundle a single .exe file from my node project. For both, the commands npm list -g <packagename> yield the respective version output, independent of the present working directory.

However, inside my batch script the commands "download" and "enigmavirtualbox" cannot be found.

Running npm root -g yields C:\Users\<username>\AppData\Roaming\npm\node_modules and looking inside that folder I can see that folders for both packages are present.

What I have tried:

  • Changing npm root as described here
  • Uninstall and reinstall packages
  • Add env. variable NODE_PATH to point to C:\Users\<username>\AppData\Roaming\npm\node_modules
  • Add C:\Users\<username>\AppData\Roaming\npm\node_modules to PATH env. variable

The same setup works on my second computer (both run Win7 64bit). Is something wrong with my node installation, or what am I doing wrong?

like image 242
bendulum Avatar asked Apr 29 '15 21:04

bendulum


People also ask

Why npm install command not found?

On Windows, you may face the “npm command not found” error if the path to nodejs and npm are not added to your path variable. To fix this, locate the path to nodejs and npm binaries. The command above should add the specified directory to the path variable.

How do I get npm packages installed globally?

To check for all globally installed packages and its dependencies, run the npm list command followed by the -g flag. This above command prints the all globally installed packages in tree view. You can also check if a specific package is installed globally or not using the npm list -g followed by package name.

Where are my global npm packages installed?

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.


1 Answers

The executable binaries and .cmd files end up in C:\Users\<username>\AppData\Roaming\npm (minus the node_modules at the end) so adding that path to the PATH env. variable fixed the issue.

With environment variables, the path can be abbreviated: %appdata\npm.

like image 170
bendulum Avatar answered Sep 18 '22 17:09

bendulum