To install node. JS First, node. JS has its own package Manager Npm,webpack needs support for node. JS v0.6 above, it is recommended to use the latest version of node. js.
Install Webpack with NPM:
$ npm install webpack -g
At this point the Webpack has been installed in the global environment, you can try it through the command line webpack -h
.
Typically, we install Webpack into a project's dependencies so that we can use the Webpack of the project's local version.
# 进入项目目录# 确定已经有 package.json,没有就通过 npm init 创建# 安装 webpack 依赖$ npm install webpack --save-dev
Webpack currently has two major versions, one in the master backbone of the stable version, one in the Webpack-2 branch of the beta, Beta has some experimental features and is incompatible with the stable version, in the official project should use stable version.
# 查看 webpack 版本信息$ npm info webpack# 安装指定版本的 webpack$ npm install [email protected]1.12.x --save-dev
If you need to use the Webpack development tool, install it separately:
$ npm install webpack-dev-server --save-dev
Node Installation Webpack