webpack执行命令的不同方式
如使用webpack3及之前的版本只需安装webpack3即可,因为之前的webpack里面集成了webpack-cli
1. 使用局部安装webpack和webpack-cli,使用package.json中scripts配置执行命令
局部安装webpack和webpack-cli
npm install webpack webpack-cli --save-dev
package.json
"scripts": { "build": "webpack" }
此时在终端执行npm run build即可
2. 使用局部安装webpack和webpack-cli
局部安装webpack和webpack-cli
npm install webpack webpack-cli --save-dev
直接在终端执行node_modules/.bin/webpack命令
3. 全局安装webpack和webpack-cli
全局安装webpack和webpack-cli
npm install webpack webpack-cli -g
局部安装
npm install webpack webpack-cli --save-dev
此时可在终端直接使用webpack命令