Node.js – calling npm from webstorm commad line tool


Im just starting with grunt in webstorm (on windows) and can't call npm (node plugin is installed and enabled, node.exe is in the system path).

npm init

what command line tool outputs:

    throw err;
Error: Cannot find module 'C:\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

Process finished with exit code 8


Best Solution

configure NPM with command line in Webstorm:

Webstorm 6 , you need to add command line support plugin :

File > Setting > IDE Settings > Plugins > Command Line Tool Support

once you added to webstorm then

File > Settings > Project Settings > Command Line Tool Support

click '+' to add > in popup window Tool Path : C:\Program Files\nodejs\npm.cmd Alias: npm (or whatever you like) visibility: select whatever you like then > OK > Apply > OK

in webstorm > Tools > Run Command > or (Coomand Line Tools Console) type command in bottom bar: npm

you will see result something like

C:\Program Files\nodejs\npm.cmd

Usage: npm

where is one of: add-user, adduser, apihelp, author, bin, bugs, c, cache, completion, config, ddp, dedupe, deprecate, docs, edit, explore, faq, find, find-dupes, get, help, help-search, home, i, info, init, install, isntall, issues, la, link, list, ll, ln, login, ls, outdated, owner, pack, prefix, prune, publish, r, rb, rebuild, remove, repo, restart, rm, root, run-script, s, se, search, set, show, shrinkwrap, star, stars, start, stop, submodule, tag, test, tst, un, uninstall, unlink, unpublish, unstar, up, update, version, view, whoami

npm -h quick help on npm -l display full usage info npm faq commonly asked questions npm help search for help on npm help npm involved overview

Specify configs in the ini-formatted file: C:\Users\kpatel.npmrc or on the command line via: npm --key value Config info can be viewed via: npm help config

npm@1.3.8 C:\Program Files\nodejs\node_modules\npm

Process finished with exit code 0 at 14:32:10. Execution time: 794 ms.

Related Question