Installation

Pre-requisites

Before getting started, make sure you have a fresh version of Node.js installed. The current LTS is an ideal starting point. You may run into a variety of issues with the older versions as they may be missing functionality webpack or related packages might need.

The next section tells you how to install webpack locally in a project.

Local Installation

npm install webpack --save-dev

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

If you are using npm scripts in your project, npm will try to look for webpack installation in your local modules for which this installation technique is useful.

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

This is standard and recommended practice.

To run the local installation of webpack you can access its bin version as node_modules/.bin/webpack

Global Installation

Note that a global webpack installation is not a recommended practice. This locks you down to a specific version of webpack and might fail in projects that use a different version.

npm install webpack -g

The webpack command is now available globally.

Bleeding Edge

If you are enthusiastic about using the latest that webpack has to offer (beware - may be unstable), you can install directly from the webpack repository using

npm install webpack/webpack#<tagname/branchname>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容