1. npm install webpack -g
如果出现:证明你的权限不够;因为webpack在全忆安装的时候会在里面写一些东西,所以需要系统权限;我们加一个 sudo npm install webpack -g就可以然后输入你的系统密码
可能是node版本问题 ,试试4.7的版本v4.4.7版本
安装npm
npm init
一路回车,再author和description处输入对应的值,注意,最后输入yes后回车会卡住,ctrl + c结束就行
npm -v 查看版本,安装成功
安装全局webpack -g表示全局
npm install [email protected]^1.15.0 -g
安装本地webpack
npm install [email protected]^1.15.0 --save-dev
webpack -v ,查看版本,显示出来就成功了
当前目录下多出一个Node_module文件
我们的webpack就装在这个里面
安装css-loader和style-loader
npm install [email protected]^0.28.1 [email protected]^0.17.0 --save-dev --registry=https://registry.npm.taobao.org
warning不用管它
css单独打包
npm install [email protected] --save-dev --registry=https://registry.npm.taobao.org
html-webpack-plugin
npm install [email protected]^2.28.0 --save-dev --registry=https://registry.npm.taobao.org
html-loader
npm install [email protected]^0.4.5 --save-dev --registry=https://registry.npm.taobao.org
url-loader
npm install url-loader --save-dev --registry=https://registry.npm.taobao.org
file-loader
npm install file-loader^0.11.1 --save-dev --registry=https://registry.npm.taobao.org
npm install [email protected] --save-dev --registry=https://registry.npm.taobao.org
webpack-dev-server启动服务