[Translation] webpack official website documentation: guide -- 2. Installation

Original translation, please indicate the source when reprinting. 

Original address: https://webpack.js.org/guides/installation/

 

 

Preconditions

Before starting, make sure you have a new version of Node.js installed . The current LTS release is an ideal starting point. You will run into a lot of problems with older versions, they may lack functional webpack or require associated packages.

The following will show you how to install webpack locally in your project .

 

local installation

npm install webpack --save-dev
 
npm install webpack@<version> --save-dev

 

If you use npm scripts in your project, npm will look for webpack in your local modules , so this installation trick is useful.

"scripts":{
    "start":"webpack --config mywebpack.config.js"
}

 

This is standard, recommended practice.

 

Install globally

Note that installing webpack globally is not recommended . This will limit you to a specific webpack version and may fail in projects using different versions.

npm install webpack -g

 webpack commands can be used globally.

 

unstable frontier

If you are interested in using the latest version provided by webpack (note: it may not be stable), you can install it directly from the webpack repository:

npm install webpack/webpack#<tagname/branchname>

 

-- End --

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326843359&siteId=291194637