From xradiograph

NodeJs: NPM

On Windows (7), npm install often requires being run as Administrator.


not found

After global installation, package cannot be run, with a message like the following:


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


Add the following location to your PATH Environment variable:
Where {username} is replaced with the current username.




What versions are available?

npm view <published-pkg-name> versions


What package version do I have?

npm list shows everything installed locally.
You can throw npm list -g for a list of EVERYTHING you’ve installed globally. Which can be a pain to parse.
So, throw npm list -g | grep <package-name> at it -- assuming you’ve got grep.


npm view <package-name> version shows the latest package available from the registry; not nesc. what you’ve got installed.


What packages do I have, anyway?


List all globally installed npm packages without the dependency tree:


npm ls -g --depth 0





npm for development

npm init

10 Habits of a Happy Node Hacker (2016) = esp. #2: “2. Use a smart .npmrc”


npm init --yes


Assuming you have set your npm-init defaults, it yields something like:

λ npm init --yes
Wrote to D:\projects\npmtest\package.json:

  "name": "npmtest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "keywords": [],
  "author": "Michael Paulukonis <> (",
  "license": "MIT"


npm version

In a clean repository (no changed files) execute

npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]

And watch your package.json get updated!


See Also:



Issues with node-gyp on Windows 7




install global package not found

I ran into the same problem as this question: npm install -g cannot find module


    throw err;
Error: Cannot find module 'colors'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (d:\Dropbox\projects\WebText\util\util.js:6:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)


And used the same solution:


For anyone else running into this, I had this problem due to my npm installing into a location that’s not on my NODE_PATH.


I did an echo and saw it was undefined.
As a test, I did set NODE_PATH=c:\users\mpaulukonis\appData\Roaming\npm\node_modules\ in the current, and the file now worked.
I added the env-var to the main user environment variables.


Not so sure about that path, though. looks ugly and funky.
What if.... node modules are on DropBox? Is that a bad idea?
How to change this location?



npm install global vs local

In general, the rule of thumb is:


  1. If you’re installing something that you want to use in your program, using require(‘whatever’), then install it locally, at the root of your project.
  2. If you’re installing something that you want to use in your shell, on the command line or something, install it globally, so that its binaries end up in your PATH environment variable.




global installs on a new system

npm -i -g eslint - EsLint?
npm -i -g http-server - Server
npm -g -g jake - Jake

Retrieved from
Page last modified on August 26, 2016, at 09:03 AM