[webpack3.8.1]Guides-1-Installation(安裝)

Installation

Pre-requisites (講在前面)

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

Local Installation (本地安裝)

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

Global Installation(全局安裝)

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的項目中,這可能會致使失敗。

Bleeding Edge (流血的邊緣)

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,並且它們不該當在產品中使用。

相關文章
相關標籤/搜索