企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
To install the latest release or a specific version, run one of the following commands: ~~~bash npm install --save-dev webpack npm install --save-dev webpack@<version> ~~~ If you're using webpack v4 or later, you'll also need to install the [CLI](https://webpack.js.org/api/cli/). ~~~bash npm install --save-dev webpack-cli ~~~ 1. Create a directory `webpack-demo`, initialize npm, install webpack locally, and install the webpack-cli (the tool used to run webpack on the command line) locally: ~~~bash mkdir webpack-demo cd webpack-demo npm init -y npm install webpack --save-dev npm install webpack-cli --save-dev ~~~ >[info] When installing a package that will be bundled into your production bundle, you should use `npm install --save`, `package.json->"dependencies"`. > If you're installing a package for development purposes (e.g. a linter, testing libraries, etc.) then you should use `npm install --save-dev`, `package.json->"devDependencies"` package.json: ~~~ { "name": "webpack-demo", "version": "1.0.0", "description": "", "private": true, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "webpack": "^4.35.2", "webpack-cli": "^3.3.5" } } ~~~ 2. Install `lodash` ~~~bash npm install --save lodash ~~~ package.json: ~~~ { "dependencies": { "lodash": "^4.17.11" } } ~~~ use `lodash` in `./src/index.js` file ~~~ const _ = require('lodash'); import _ from 'lodash'; ~~~