1、建立空的文件夹newDemo
2、初始化:npm init =>出现package.json文件
3、下载webpack:npm install webpack --save-dev =>package.json文件中出现一行webpack的指令
4、安装完成后输入:cnpm install webpack-dev-server --save-dev =>多出一行webpack-dev-server的指令
5、新建webpack.config.js基本配置文件,在文件中初始化
var config= {};
module.exports = config;
6、在package.json中配置dev指令,scripts中添加:"dev":"webpack-dev-server --open --config webpack.config.js"
7、运行,看是否配置成功:npm run dev
8、如果报错:cannot find module "webpack-cli-......"则安装webpack-cli =>npm install webpack-cli
9、在运行,如果报错:webpack-dev-server 不是内部文件......:删除node_modules文件夹,并依次运行:npm install ->npm run dev
网友评论