Webpack command not found

*爱你&永不变心* 提交于 2019-12-05 00:28:56

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

Arnold Gandarillas

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.

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.

gilchris

If you want to use global installation, you can find webpack script in [node_installed_path]/lib/node_modules/webpack/bin/, you can use with absolute path, adding to PATH environment variable, or symbolic link, etc.

If you want to use local installation, find it in ./node_modules/.bin/.

I recommand using local installation (for same reason about babel).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!