Reputation: 5369
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
dev => Edit 'dev' settings:
Upvotes: 22
Views: 46001
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
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:
...
" 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. /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.Upvotes: 1
Reputation: 1
In my case ubuntu 18.04+PHPSTORM Helps this:
apt-get remove nodejs
apt-get remove npm
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
sudo apt-get install -y nodejs
Upvotes: 0
Reputation: 56
I have fixed this problem by update the latest version of nodejs
Upvotes: -1
Reputation: 161
Try changing your NPM patch no /usr/share/npm. This works for me.
Upvotes: 0
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
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
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
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
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.
Upvotes: 31