简体   繁体   English

安装webpack来分离依赖项?

[英]Install webpack to separate dependencies?

Im going through a tutorial on webpack (third day and still confused as anything!) and Im combing through the commands: 我正在浏览关于webpack的教程(第三天,仍然感到困惑!),然后通过命令进行梳理:

npm i webpack --save-dev

The above command installs the webpack as a node module to '--save-dev'? 上面的命令将webpack作为节点模块安装到“ --save-dev”? Im confused what '--save-dev' is. 我很困惑'--save-dev'是什么。 And is it a normal convention for webpacks to use? 这是webpack的常规用法吗?

Also where is this dependency being saved? 还要将此依赖项保存在哪里? I dont find any reference to it in webpack.config.js or package.json for that matter? 我没有在webpack.config.jspackage.json找到对此的任何引用吗?

Many thanks 非常感谢

npm i webpack --save-dev is a shorthand for npm install webpack --save-dev . npm i webpack --save-devnpm install webpack --save-dev的简写。 The --save-dev flag tells npm to save the dependency as a development dependency , ie it will be listed in devDependencies in package.json instead of the "normal" dependencies section. --save-dev标志告诉npm将依赖项另存为开发依赖项 ,即它将在package.json devDependencies中而不是“ normal” dependencies部分中列出。

What this means is that development dependencies are dependencies that are not required to run your application, but only for development purposes like running unit tests, bundling the application, etc. etc. 这意味着开发依赖关系是运行您的应用程序不需要的依赖关系,仅用于开发目的,例如运行单元测试,捆绑应用程序等。

From the documentation for npm install : npm install文档中

-D, --save-dev: Package will appear in your devDependencies. -D,--save-dev:软件包将出现在您的devDependencies中。

Here is another stackoverflow post on differences between "normal" dependencies and development dependencies. 是关于“正常”依赖和开发依赖之间差异的另一篇stackoverflow文章。

Cheers, Alex 干杯,亚历克斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM