Reputation: 557
Weird behaviour on my OSX Yosemite: from one day to another all my node modules installed by npm install -g
were not found via the Terminal.
I'm not sure if this is due to my node v4.0.0 install the day before.
Upvotes: 13
Views: 25355
Reputation: 13222
Webpack is in your ./node_modules/.bin/ folder so instead of giving just webpack as the command try this.
./node_modules/.bin/webpack
You have the npm bin command to get the folder where npm will install executables.
You can use the scripts property of your package.json to use webpack from this directory which will be exported.
"scripts": { "scriptName": "webpack --config etc..." } For example:
"scripts": { "build": "webpack --config webpack.config.js" } You can
then run it with:
npm run build
Or even with arguments:
npm run build -- <args>
This allow you to have you webpack.config.js in the root folder of your project without having webpack globally installed or having your webpack configuration in the node_modules folder.
Upvotes: 1
Reputation: 393
Install it globally
npm i -g webpack
If you will work with webpack, install webpack-dev-server too
npm i -g webpack-dev-server
After I Install this two command I also found errors when run the
webpack
command so I figure out the problem by changing the version of webpack so I Install
npm install [email protected]
and every thing work fine for me.
I recommend you first learn a bit about npm and then webpack. You will struggle a lot. but finally you will find the right destination.
Upvotes: 5
Reputation: 321
Try this
echo $(npm config get prefix)/bin
you will get STRING, which should include to your .bash_profile such way
export PATH=$PATH:STRING
Upvotes: 9
Reputation: 557
I've finally also used NVM for multiple NodeJS versions management and everything went back under control.
Upvotes: 1