WebStorm - error: Please specify npm package

Viewed 39192

Webstorm throws an error when trying to run a command specified in package.json:

"devDependencies": {},
      "scripts": {
        "dev": "./node_modules/.bin/webpack-dev-server --content-base src --inline --hot",
        "test": "echo \"Error: no test specified\" && exit 1"
      },

I've used this script with Webstorm on other computers (Linux/Windows). On this one (Linux), it does not seem to work out of a sudden. It used to be fine. I've just upgraded Webstorm. From CLI, the 'dev'command works fine, it's something to do with Webstorm configuration. The In Settings => Languages & Frameworks => NOde.js and NPM the node interpreter is specified as /usr/bin/node which is the correct path. I also clicked to Enable Node.js Core library. Still in the NPM window on Webstorm, when I want to run the 'dev' script, it throws the above mentioned error. The project is a react project, if that matters.

In the past, it ran fine. Please advise.

Edit: Added a screenshot - Defaults

enter image description here

dev => Edit 'dev' settings:

enter image description here

12 Answers

if you use Node Version Manager like me, it was a folder in which the bin folder was:

~/.nvm/versions/node/v8.9.1/lib/node_modules/npm

If you installed Node.JS from the official website (not from the apt repository), you probably put the installation folder somewhere at /opt/node-v10.13.0-linux-x64 (depending on your preferences).

If so, you should modify your WebStorm settings as follows:

  1. Ctrl+Alt+S to bring up Settings window
  2. Go to "Languages and Frameworks" tab and select "Node.js & NPM"
  3. On the right side,
    • for field "Node interpreter" click on "..." and in the opened window click on "+" button and "Add local". In the drop-down list select /opt/node-v10.13.0-linux-x64/bin/node and click OK.
    • now, for a "Package manager" field click "..." next to it, and just select the folder /opt/node-v10.13.0-linux-x64/bin and click OK. As it was pointed out already, for npm WebStorm doesn't expect you to provide the full path to npm binary, just to the folder where this binary is.
  4. Click Apply.
  5. Now you should be all set to go

Try changing your NPM patch no /usr/share/npm. This works for me.

Just update Webstorm to 2018.3. Problem solved

In my case ubuntu 18.04+PHPSTORM Helps this:

apt-get remove nodejs
apt-get remove npm

Using Ubuntu

curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs

I have fixed this problem by update the latest version of nodejs

Related