gpt4 book ai didi

javascript - Lodash 在 Webpack 中安装指南页面

转载 作者:行者123 更新时间:2023-12-03 01:25:31 32 4
gpt4 key购买 nike

当我看this时他们使用 npm install --save lodash 来安装 lodash。但当我看 this页面,package.json 如下所示:

{
"name": "webpack-demo",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
===> "devDependencies": { <===
"webpack": "^4.0.1",
"webpack-cli": "^2.0.9",
"lodash": "^4.17.5" <- ???
}
}

我错过了什么吗?

最佳答案

No need to get confused. It's pretty simple.

use below command if you need to lodash in the production

npm install lodash --save

use below command if you don't need to lodash in the production

npm install lodash --save-dev

Once you are done. lodash's functions will be available globally. If you get any error like _ is not defined. Then you can import lodash like this

import _ from 'lodash'; OR let _ = require('lodash')

关于javascript - Lodash 在 Webpack 中安装指南页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51568477/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com