Before we begin, make sure you have a fresh version of Node.js installed. The current Long Term Support (LTS) release is an ideal starting point. You may run into a variety of issues with the older versions as they may be missing functionality webpack and/or its related packages require.node
在咱们开始以前,请你确认已经安装了最新版本的Node.js,最理想的版本就是最新的长期支持版本了。若是你使用了旧版本,你可能会由于缺失功能或者缺失相关包而不停地翻论坛。webpack
To install the latest release or a specific version, run one of the following commands:web
为了安装最新的发行版或者肯定版本,咱们须要执行下面任意一个命令,即执行npm
npm install --save-dev webpack
或者ide
npm install --save-dev webpack@<version>
Installing locally is what we recommend for most projects. This makes it easier to upgrade projects individually when breaking changes are introduced. Typically webpack is run via one or more npm scripts which will look for a webpack installation in your local node_modules directory:测试
对于大部分项目,咱们都推荐本地安装。当第三方库改变发生时,项目的独立升级会比较容易。webpack一般经过一个或者多个npm脚原本运行,npm会查找本地的node_modules目录中寻找webpack,进行安装。ui
"scripts": { "start": "webpack --config webpack.config.js" }
P.S.:breaking changes | introducedthis
To run the local installation of webpack you can access its bin version as node_modules/.bin/webpack.idea
为了执行webpack的本地安装,您能够执行它的bin版本:node_modules/.bin/webpack。code
The following NPM installation will make webpack available globally:
下面的NPM的安装方式,可使得webpack变得全局可用。(就是在任意一个目录下都能调用)
npm install --global webpack
Note that this is not a recommended practice. Installing globally locks you down to a specific version of webpack and could fail in projects that use a different version.
须要注意的是,这种方式咱们并不推荐!全局安装将会锁定你如今的webpack安装版本,并且在使用别的版本的webpack的项目中,这可能会致使失败。
If you are enthusiastic about using the latest that webpack has to offer, you can install beta versions or even directly from the webpack repository using the following commands:
若是你对于最新的webpack所提供的服务感到狂热,你可使用以下的命令安装webpack测试版本:
npm install webpack@beta npm install webpack/webpack#<tagname/branchname>
Take caution when installing these bleeding edge releases! They may still contain bugs and therefore should not be used in production.
当你安装这些正在流淌着鲜血的测试版本时必定要当心呀!它们极有可能包含bug,并且它们不该当在产品中使用。