npm – Webpack command not found

npm – Webpack command not found

Your webpack exists in ./node_modules/.bin/ folder . So you should execute this command :

./node_modules/.bin/webpack

Check out the answer in this thread .

webpack command not working

As a good practice is recommended to install webpack and webpack-dev-server locally, more info here.

yarn add webpack webpack-dev-server --dev
# or
npm install webpack webpack-dev-server --save-dev

Then you can add these lines to your scripts section in your package.json file.

scripts: {
  build: webpack --progress --colors,
  start: webpack-dev-server --progress --colors
}

and finally

npm start
npm run build

Note: You need to have a webpack.config.js in the root folder to make it run correctly.

npm – Webpack command not found

I needed to manually install:

npm install --save-dev webpack-cli

I guess its needed so that Angular CLI actually understands the commands related to Webpack.

Leave a Reply

Your email address will not be published.