Wasteland
Wasteland

Reputation: 5369

WebStorm - error: Please specify npm package

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

Upvotes: 22

Views: 46001

Answers (12)

Michał Lepczyński
Michał Lepczyński

Reputation: 403

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

Upvotes: 8

Igor
Igor

Reputation: 121

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

Upvotes: 1

Alexey Olshevskiy
Alexey Olshevskiy

Reputation: 1

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

Upvotes: 0

Morris Tai
Morris Tai

Reputation: 3

Just update Webstorm to 2018.3. Problem solved

Upvotes: 0

Noah Drisort
Noah Drisort

Reputation: 56

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

Upvotes: -1

Fernando Magrosoto
Fernando Magrosoto

Reputation: 161

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

Upvotes: 0

Ahmad Muzakki
Ahmad Muzakki

Reputation: 1088

just want to add some reference. in my machine it's in /usr/share/npm so just fill that field with that.

Upvotes: 18

chris mahn
chris mahn

Reputation: 117

On Xubuntu and Linux Mint, use /usr/bin/lib/nodejs/npm.

Upvotes: 0

Prashanth Adepu
Prashanth Adepu

Reputation: 69

In Linux/Ubuntu: One of the reasons why webstorm throws this error is because of false directory names for node interpreter ("Run > Edit configurations > Defaults> npm > node interpreter").

In the recent node installation the default node interpreter directory is usr/bin/nodejs instead of usr/bin/node.

So, correct the node interpreter from "usr/bin/node" to "usr/bin/nodejs" and it works fine.

Upvotes: 4

Ortwin Angermeier
Ortwin Angermeier

Reputation: 6183

On Ubuntu, if you have installed npm/nodejs via apt, use the /usr/share/npm folder for the npm package.

sudo apt-get install npm nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node

Upvotes: 22

lpalli
lpalli

Reputation: 1

On Windows I was unable to solve the problem using the Npm package configuration setting using a custom npm installation.

Installing a standard npm via the node.js solved the problem in WebStorm without having to set the Npm package configuration.

Upvotes: 0

Anthony Drogon
Anthony Drogon

Reputation: 1864

Ran into the same issue after upgrading from 11.0.3 to 2016.1. Not sure if some configuration was wrongly copied or if they added a new field to specify the npm package.

Go to

Run > Edit Configurations > Defaults > npm

Browse to select a Node interpreter, using the [...] button.

You should find the Npm package field, fill it with YOUR_PATH_TO_NODE/lib/node_modules/npm.

If it does not work right away, restart WebStorm so that it is taken into account.

Run/Debug Configurations > NPM screenshot

Upvotes: 31

Related Questions