webpack command not working
webpack
is not only in your node-modules/webpack/bin/
directory, it's also linked in node_modules/.bin
.
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.
You can run npx webpack
. The npx command, which ships with Node 8.2/npm 5.2.0 or higher, runs the webpack binary (./node_modules/.bin/webpack) of the webpack package.
Source of info: https://webpack.js.org/guides/getting-started/