[英]What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
This documentation answers my question very poorly.该文档非常糟糕地回答了我的问题。 I didn't understand those explanations.我不明白那些解释。 Can someone say in simpler words?有人能用更简单的话说吗? Maybe with examples if it's hard to choose simple words?如果很难选择简单的单词,也许有例子?
EDIT also added peerDependencies
, which is closely related and might cause confusion. EDIT还添加了peerDependencies
,这是密切相关的,可能会引起混淆。
Summary of important behavior differences:重要行为差异总结:
dependencies
are installed on both:两个都安装了dependencies
项:
npm install
from a directory that contains package.json
从包含package.json
的目录中npm install
npm install $package
on any other directory npm install $package
在任何其他目录上devDependencies
are: devDependencies
是:
npm install
on a directory that contains package.json
, unless you pass the --production
flag (go upvote Gayan Charith's answer ), or if the NODE_ENV=production
environment variable is set也安装在npm install
包含package.json
的目录上,除非您通过--production
标志(去投票 Gayan Charith 的答案),或者如果设置了NODE_ENV=production
环境变量npm install "$package"
on any other directory, unless you give it the --dev
option.没有安装在任何其他目录上的npm install "$package"
上,除非你给它--dev
选项。 peerDependencies
: peerDependencies
:
npm install
, and you have to solve the dependency yourself manually.预计从 3.0 开始(未经测试):如果在npm install
上丢失,则发出警告,您必须自己手动解决依赖关系。 When running, if the dependency is missing, you get an error (mentioned by @nextgentech ) This explains it nicely: https://flaviocopes.com/npm-peer-dependencies/运行时,如果缺少依赖项,则会出现错误( @nextgentech提到)这很好地解释了它: https ://flaviocopes.com/npm-peer-dependencies/Transitivity (mentioned by Ben Hutchison ):传递性( Ben Hutchison提到):
dependencies
are installed transitively: if A requires B, and B requires C, then C gets installed, otherwise, B could not work, and neither would A. dependencies
是传递安装的:如果 A 需要 B,而 B 需要 C,则安装 C,否则,B 不能工作,A 也不能工作。
devDependencies
is not installed transitively. devDependencies
不会传递安装。 Eg we don't need to test B to test A, so B's testing dependencies can be left out.例如,我们不需要测试 B 来测试 A,因此可以省略 B 的测试依赖项。
Related options not discussed here:此处未讨论的相关选项:
bundledDependencies
which is discussed on the following question: Advantages of bundledDependencies over normal dependencies in npm bundledDependencies
在以下问题上进行了讨论: 与 npm 中的正常依赖关系相比 bundledDependencies 的优势optionalDependencies
(mentioned by Aidan Feldman ) optionalDependencies
( 由 Aidan Feldman提到)dependencies
are required to run, devDependencies
only to develop, eg: unit tests, CoffeeScript to JavaScript transpilation, minification, ... dependencies
项需要运行, devDependencies
仅用于开发,例如:单元测试,CoffeeScript 到 JavaScript 的转换,缩小,...
If you are going to develop a package, you download it (eg via git clone
), go to its root which contains package.json
, and run:如果你要开发一个包,你下载它(例如通过git clone
),去它包含package.json
的根目录,然后运行:
npm install
Since you have the actual source, it is clear that you want to develop it, so by default, both dependencies
(since you must, of course, run to develop) and devDependency
dependencies are also installed.既然你有实际的源码,很明显你想开发它,所以默认情况下, dependencies
项(因为你当然必须运行开发)和devDependency
依赖项也都安装了。
If however, you are only an end user who just wants to install a package to use it, you will do from any directory:但是,如果您只是想要安装软件包以使用它的最终用户,您可以从任何目录执行:
npm install "$package"
In that case, you normally don't want the development dependencies, so you just get what is needed to use the package: dependencies
.在这种情况下,您通常不需要开发依赖项,因此您只需获取使用包所需的内容: dependencies
。
If you really want to install development packages in that case, you can set the dev
configuration option to true
, possibly from the command line as:如果您真的想在这种情况下安装开发包,您可以将dev
配置选项设置为true
,可能从命令行中设置为:
npm install "$package" --dev
The option is false
by default since this is a much less common case.该选项默认为false
,因为这种情况不太常见。
(Tested before 3.0) (3.0前测试)
Source: https://nodejs.org/en/blog/npm/peer-dependencies/来源: https ://nodejs.org/en/blog/npm/peer-dependencies/
With regular dependencies, you can have multiple versions of the dependency: it's simply installed inside the node_modules
of the dependency.使用常规依赖项,您可以拥有多个版本的依赖项:它只是安装在依赖项的node_modules
中。
Eg if dependency1
and dependency2
both depend on dependency3
at different versions the project tree will look like:例如,如果dependency1
和dependency2
都dependency3
于不同版本的dependency3,则项目树将如下所示:
root/node_modules/
|
+- dependency1/node_modules/
| |
| +- dependency3 v1.0/
|
|
+- dependency2/node_modules/
|
+- dependency3 v2.0/
Plugins, however, are packages that normally don't require the other package, which is called the host in this context.但是,插件是通常不需要其他包的包,在此上下文中称为主机。 Instead:反而:
Eg if dependency1
and dependency2
peer depend on dependency3
, the project tree will look like:例如,如果dependency1
和dependency2
peer 依赖于dependency3
,项目树将如下所示:
root/node_modules/
|
+- dependency1/
|
+- dependency2/
|
+- dependency3 v1.0/
This happens even though you never mention dependency3
in your package.json
file.即使您从未在package.json
文件中提及dependency3
,也会发生这种情况。
I think this is an instance of the Inversion of Control design pattern.我认为这是控制反转设计模式的一个实例。
A prototypical example of peer dependencies is Grunt, the host, and its plugins.对等依赖的一个典型例子是 Grunt、主机和它的插件。
For example, on a Grunt plugin like https://github.com/gruntjs/grunt-contrib-uglify , you will see that:例如,在像https://github.com/gruntjs/grunt-contrib-uglify这样的 Grunt 插件上,您将看到:
grunt
is a peer-dependency
grunt
是peer-dependency
require('grunt')
is under tests/
: it's not actually used by the program.唯一的require('grunt')
在tests/
中:程序实际上并未使用它。 Then, when the user will use a plugin, he will implicitly require the plugin from the Gruntfile
by adding a grunt.loadNpmTasks('grunt-contrib-uglify')
line, but it's grunt
that the user will call directly.然后,当用户使用插件时,他会通过添加grunt.loadNpmTasks('grunt-contrib-uglify')
行从Gruntfile
中隐式地要求该插件,但用户会直接调用grunt
。
This would not work then if each plugin required a different Grunt version.如果每个插件都需要不同的 Grunt 版本,这将不起作用。
I think the documentation answers the question quite well, maybe you are just not familiar enough with node / other package managers.我认为文档很好地回答了这个问题,也许你对节点/其他包管理器不够熟悉。 I probably only understand it because I know a bit about Ruby bundler.我可能只是了解它,因为我对 Ruby bundler 有所了解。
The key line is:关键线是:
These things will be installed when doing npm link or npm install from the root of a package and can be managed like any other npm configuration parameter.这些东西将在从包的根目录执行 npm link 或 npm install 时安装,并且可以像任何其他 npm 配置参数一样进行管理。 See npm-config(7) for more on the topic.有关该主题的更多信息,请参阅 npm-config(7)。
And then under npm-config(7) find dev
:然后在 npm-config(7) 下找到dev
:
Default: false
Type: Boolean
Install dev-dependencies along with packages.
如果您不想安装 devDependencies,可以使用npm install --production
例如,mocha 通常是一个 devDependency,因为在生产中不需要测试,而 express 是一个依赖项。
dependencies依赖关系
Dependencies that your project needs to run, like a library that provides functions that you call from your code.您的项目需要运行的依赖项,例如提供您从代码中调用的函数的库。
They are installed transitively (if A depends on B depends on C, npm install on A will install B and C).它们是传递安装的(如果 A 依赖于 B 依赖于 C,则 npm install on A 将安装 B 和 C)。
Example: lodash: your project calls some lodash functions.示例:lodash:您的项目调用了一些 lodash 函数。
devDependencies开发依赖
Dependencies you only need during development or releasing, like compilers that take your code and compile it into javascript, test frameworks or documentation generators.您仅在开发或发布期间需要的依赖项,例如将您的代码编译成 javascript、测试框架或文档生成器的编译器。
They are not installed transitively (if A depends on B dev-depends on C, npm install on A will install B only).它们不是可传递安装的(如果 A 依赖于 B dev-依赖于 C,则 npm install on A 将仅安装 B)。
Example: grunt: your project uses grunt to build itself.示例: grunt:您的项目使用 grunt 来构建自己。
peerDependencies peerDependencies
Dependencies that your project hooks into, or modifies, in the parent project, usually a plugin for some other library or tool.您的项目在父项目中挂钩或修改的依赖项,通常是其他库或工具的插件。 It is just intended to be a check, making sure that the parent project (project that will depend on your project) has a dependency on the project you hook into.它只是为了检查,确保父项目(将依赖于您的项目的项目)依赖于您挂钩的项目。 So if you make a plugin C that adds functionality to library B, then someone making a project A will need to have a dependency on B if they have a dependency on C.因此,如果您制作了一个插件 C 来为库 B 添加功能,那么制作项目 A 的人将需要依赖于 B,如果他们依赖于 C。
They are not installed (unless npm < 3), they are only checked for.它们没有安装(除非 npm < 3),它们只被检查。
Example: grunt: your project adds functionality to grunt and can only be used on projects that use grunt.示例: grunt:您的项目为 grunt 添加了功能,并且只能用于使用 grunt 的项目。
This documentation explains peer dependencies really well: https://nodejs.org/en/blog/npm/peer-dependencies/本文档很好地解释了对等依赖项: https ://nodejs.org/en/blog/npm/peer-dependencies/
Also, the npm documentation has been improved over time, and now has better explanations of the different types of dependencies: https://github.com/npm/cli/blob/latest/docs/content/configuring-npm/package-json.md#devdependencies此外,随着时间的推移,npm 文档得到了改进,现在对不同类型的依赖项有了更好的解释: https ://github.com/npm/cli/blob/latest/docs/content/configuring-npm/package-json .md#devdependencies
To save a package to package.json as dev dependencies:要将包保存到package.json作为开发依赖项:
npm install "$package" --save-dev
When you run npm install
it will install both devDependencies
and dependencies
.当你运行npm install
时,它会同时安装devDependencies
和dependencies
。 To avoid install devDependencies
run:为了避免安装devDependencies
运行:
npm install --production
There are some modules and packages only necessary for development, which are not needed in production.有一些模块和包仅用于开发,而在生产中不需要。 Like it says it in the documentation :就像它在文档中所说的那样:
If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.如果有人计划在他们的程序中下载和使用您的模块,那么他们可能不想或不需要下载和构建您使用的外部测试或文档框架。 In this case, it's best to list these additional items in a devDependencies hash.在这种情况下,最好在 devDependencies 哈希中列出这些附加项。
peerDependencies
didn't quite make sense for me until I read this snippet from a blog post on the topic Ciro mentioned above : peerDependencies
对我来说不太有意义,直到我从一篇关于上面提到的 Ciro主题的博客文章中阅读了这段代码:
What [ plugins ] need is a way of expressing these “dependencies” between plugins and their host package. [插件] 需要的是一种表达插件和它们的宿主包之间的“依赖关系”的方式。 Some way of saying, “I only work when plugged in to version 1.2.x of my host package, so if you install me, be sure that it's alongside a compatible host.”某种说法,“我只在插入我的主机包的 1.2.x 版本时工作,所以如果你安装我,请确保它与兼容的主机一起使用。” We call this relationship a peer dependency.我们称这种关系为对等依赖。
peerDependencies
are for plugins, libraries that require a "host" library to perform their function, but may have been written at a time before the latest version of the host was released. peerDependencies
用于插件,需要“主机”库来执行其功能的库,但可能是在最新版本的主机发布之前编写的。
That is, if I write PluginX v1
for HostLibraryX v3
and walk away, there's no guarantee PluginX v1
will work when HostLibraryX v4
(or even HostLibraryX v3.0.1
) is released.也就是说,如果我为HostLibraryX v3
编写PluginX v1
并离开,则无法保证PluginX v1
在HostLibraryX v4
(甚至HostLibraryX v3.0.1
)发布时会起作用。
From the point of view of the plugin, it only adds functions to the host library.从插件的角度来看,它只是向宿主库添加了功能。 I don't really "need" the host to add a dependency to a plugin, and plugins often don't literally depend on their host.我并不真正“需要”主机向插件添加依赖项,并且插件通常并不真正依赖于它们的主机。 If you don't have the host, the plugin harmlessly does nothing.如果您没有主机,则该插件不会无害地执行任何操作。
This means dependencies
isn't really the right concept for plugins.这意味着dependencies
并不是插件的正确概念。
Even worse, if my host was treated like a dependency, we'd end up in this situation that the same blog post mentions (edited a little to use this answer's made up host & plugin):更糟糕的是,如果我的主机被视为依赖项,我们最终会遇到 同一篇博客文章提到的这种情况(稍作编辑以使用此答案由主机和插件组成):
But now, [if we treat the contemporary version of HostLibraryX as a dependency for PluginX,] running
npm install
results in the unexpected dependency graph of但是现在,[如果我们将 HostLibraryX 的当代版本视为 PluginX 的依赖项,] 运行npm install
会导致意外的依赖关系图├── HostLibraryX@4.0.0 └─┬ PluginX@1.0.0 └── HostLibraryX@3.0.0
I'll leave the subtle failures that come from the plugin using a different [HostLibraryX] API than the main application to your imagination.我会将插件使用与主应用程序不同的 [HostLibraryX] API 带来的细微故障留给您想象。
... that's the whole point of plugins. ...这就是插件的重点。 Now if the host was nice enough to include dependency information for all of its plugins, that'd solve the problem, but that'd also introduce a huge new cultural problem : plugin management!现在,如果主机足够好,可以包含所有插件的依赖信息,那将解决问题,但这也会引入一个巨大的新文化问题:插件管理!
The whole point of plugins is that they can pair up anonymously.插件的全部意义在于它们可以匿名配对。 In a perfect world, having the host manage 'em all would be neat & tidy, but we're not going to require libraries herd cats.在一个完美的世界里,让主人管理它们会很整洁,但我们不需要图书馆放猫。
Instead, we have the concept of being peers.相反,我们有成为同行的概念。 Neither host nor plugin sits in the other's dependency bucket.主机和插件都不在对方的依赖桶中。 Both live at the same level of the dependency graph.两者都生活在依赖图的同一级别。
If I'm PluginX v1
and expect a peer of (that is, have a peerDependency of ) HostLibraryX v3
, I'll say so.如果我是PluginX v1
并且期望HostLibraryX v3
的对等点(即具有 peerDependency 的),我会这么说。 If you've auto-upgraded to the latest HostLibraryX v4
(note that's version 4 ) AND have Plugin v1
installed, you need to know, right?如果您已自动升级到最新的HostLibraryX v4
(请注意是版本4 )并安装了Plugin v1
,您需要知道,对吗?
npm
can't manage this situation for me -- npm
无法为我处理这种情况——
"Hey, I see you're using
PluginX v1
! I'm automatically downgradingHostLibraryX
from v4 to v3, kk?" “嘿,我看到你在使用PluginX v1
!我正在自动将HostLibraryX
从 v4 降级到 v3,kk?”
... or... ... 或者...
"Hey I see you're using
PluginX v1
. That expectsHostLibraryX v3
, which you've left in the dust during your last update. To be safe, I'm automatically uninstallingPlugin v1
!!1! “嘿,我看到您正在使用PluginX v1
。这需要HostLibraryX v3
,您在上次更新期间已将其留在尘埃中。为了安全起见,我将自动卸载Plugin v1
!!1!
How about no, npm?!不怎么样,npm?!
So npm doesn't.所以 npm 没有。 It alerts you to the situation, and lets you figure out if HostLibraryX v4
is a suitable peer for Plugin v1
.它会提醒您注意这种情况,并让您确定HostLibraryX v4
是否是Plugin v1
的合适对等点。
Good peerDependency
management in plugins will make this concept work more intuitively in practice.插件中良好的peerDependency
管理将使这个概念在实践中更直观地工作。 From the blog post , yet again...从博客文章中,再次...
One piece of advice: peer dependency requirements, unlike those for regular dependencies, should be lenient.一条建议:与常规依赖不同,对等依赖要求应该宽松。 You should not lock your peer dependencies down to specific patch versions.您不应该将您的对等依赖项锁定到特定的补丁版本。 It would be really annoying if one Chai plugin peer-depended on Chai 1.4.1, while another depended on Chai 1.5.0, simply because the authors were lazy and didn't spend the time figuring out the actual minimum version of Chai they are compatible with.如果一个 Chai 插件对等依赖于 Chai 1.4.1,而另一个依赖于 Chai 1.5.0,那真的很烦人,仅仅是因为作者很懒,没有花时间弄清楚他们是 Chai 的实际最低版本兼容。
A simple explanation that made it more clear to me is:一个让我更清楚的简单解释是:
When you deploy your app, modules in dependencies need to be installed or your app won't work.当您部署应用程序时,需要安装依赖项中的模块,否则您的应用程序将无法运行。 Modules in devDependencies don't need to be installed on the production server since you're not developing on that machine. devDependencies 中的模块不需要安装在生产服务器上,因为您不是在该机器上开发。 link 关联
I'd like to add to the answer my view on these dependencies explanations我想在答案中添加我对这些依赖项解释的看法
dependencies
are used for direct usage in your codebase, things that usually end up in the production code, or chunks of code dependencies
项用于在您的代码库中直接使用,通常最终出现在生产代码中的东西,或代码块devDependencies
are used for the build process, tools that help you manage how the end code will end up, third party test modules, (ex. webpack stuff) devDependencies
用于构建过程,帮助您管理最终代码的工具,第三方测试模块,(例如 webpack 的东西)I found a simple explanation.我找到了一个简单的解释。
Short Answer:简短的回答:
dependencies "...are those that your project really needs to be able to work in production."依赖项“......是您的项目真正需要能够在生产中工作的那些。”
devDependencies "...are those that you need during development." devDependencies “......是您在开发过程中需要的那些。”
peerDependencies "if you want to create and publish your own library so that it can be used as a dependency" peerDependencies “如果你想创建和发布自己的库,以便它可以用作依赖项”
More details in this post: https://code-trotter.com/web/dependencies-vs-devdependencies-vs-peerdependencies这篇文章中的更多细节: https ://code-trotter.com/web/dependencies-vs-devdependencies-vs-peerdependencies
In short简而言之
Dependencies - npm install <package> --save-prod
installs packages required by your application in production environment.依赖项 - npm install <package> --save-prod
在生产环境中安装应用程序所需的包。
DevDependencies - npm install <package> --save-dev
installs packages required only for local development and testing DevDependencies - npm install <package> --save-dev
安装本地开发和测试所需的包
Just typing npm install
installs all packages mentioned in the package.json只需键入npm install
安装 package.json 中提到的所有包
so if you are working on your local computer just type npm install
and continue :)因此,如果您在本地计算机上工作,只需键入npm install
并继续 :)
Dependencies vs dev dependencies依赖与开发依赖
Dev dependencies are modules which are only required during development whereas dependencies are required at runtime.开发依赖项是仅在开发期间需要的模块,而在运行时需要依赖项。 If you are deploying your application, dependencies has to be installed, or else your app simply will not work.如果您正在部署应用程序,则必须安装依赖项,否则您的应用程序将无法运行。 Libraries that you call from your code that enables the program to run can be considered as dependencies.您从代码中调用的使程序能够运行的库可以被视为依赖项。
Eg- React , React - dom例如-反应,反应-dom
Dev dependency modules need not be installed in the production server since you are not gonna develop in that machine .compilers that covert your code to javascript , test frameworks and document generators can be considered as dev-dependencies since they are only required during development .开发依赖模块不需要安装在生产服务器中,因为您不会在那台机器上进行开发。将代码转换为 javascript 的编译器、测试框架和文档生成器可以被视为开发依赖,因为它们仅在开发期间需要。
Eg- ESLint , Babel , webpack例如- ESLint 、 Babel 、 webpack
@FYI, @供参考,
mod-a
dev-dependents:
- mod-b
dependents:
- mod-c
mod-d
dev-dependents:
- mod-e
dependents:
- mod-a
----
npm install mod-d
installed modules:
- mod-d
- mod-a
- mod-c
----
checkout the mod-d code repository
npm install
installed modules:
- mod-a
- mod-c
- mod-e
If you are publishing to npm, then it is important that you use the correct flag for the correct modules.如果您要发布到 npm,那么为正确的模块使用正确的标志很重要。 If it is something that your npm module needs to function, then use the "--save" flag to save the module as a dependency.如果它是你的 npm 模块需要运行的东西,那么使用“--save”标志将模块保存为依赖项。 If it is something that your module doesn't need to function but it is needed for testing, then use the "--save-dev" flag.如果它是您的模块不需要运行但需要进行测试的东西,则使用“--save-dev”标志。
# For dependent modules
npm install dependent-module --save
# For dev-dependent modules
npm install development-module --save-dev
These are the packages that your package needs to run, so they will be installed when people run这些是你的包需要运行的包,所以它们会在人们运行时安装
npm install PACKAGE-NAME
An example would be if you used jQuery in your project.例如,如果您在项目中使用了 jQuery。 If someone doesn't have jQuery installed, then it wouldn't work.如果有人没有安装 jQuery,那么它将无法工作。 To save as a dependency, use要保存为依赖项,请使用
npm install --save
These are the dependencies that you use in development, but isn't needed when people are using it, so when people run npm install
, it won't install them since the are not necessary.这些是您在开发中使用的依赖项,但在人们使用它时不需要,因此当人们运行npm install
时,它不会安装它们,因为它们不是必需的。 For example, if you use mocha
to test, people don't need mocha
to run, so npm install
doesn't install it.例如,如果你使用mocha
进行测试,人们不需要mocha
来运行,所以npm install
不会安装它。 To save as a dev dependency, use要另存为开发依赖项,请使用
npm install PACKAGE --save-dev
These can be used if you want to create and publish your own library so that it can be used as a dependency.如果您想创建和发布自己的库以便将其用作依赖项,则可以使用这些。 For example, if you want your package to be used as a dependency in another project, then these will also be installed when someone installs the project which has your project as a dependency.例如,如果您希望您的包在另一个项目中用作依赖项,那么当有人安装将您的项目作为依赖项的项目时,也会安装这些包。 Most of the time you won't use peer dependencies.大多数情况下,您不会使用对等依赖项。
When trying to distribute an npm package you should avoid using dependencies
.在尝试分发 npm 包时,您应该避免使用dependencies
项。 Instead you need to consider adding it into peerDependencies
.相反,您需要考虑将其添加到peerDependencies
中。
Most of the time dependencies are just a bunch of libraries that describes your ecosystem.大多数时候,依赖关系只是一堆描述你的生态系统的库。 Unless, you're really using a specific version of a library you should instead let the user choose whether or not to install that library and which version to choose by adding it into the peerDependencies.除非,您真的使用特定版本的库,否则您应该让用户选择是否安装该库以及通过将其添加到 peerDependencies 中来选择哪个版本。
dependencies : packages that your project/package needs to work in production.依赖项:您的项目/包需要在生产中工作的包。
devDependencies : packages that your project/package needs to work while development but are not needed on production (eg: testing packages) devDependencies :您的项目/包在开发时需要工作但在生产中不需要的包(例如:测试包)
peerDependencies : packages that your project/package needs to work in tandem with (“colaborating” with them) or as a base, useful mainly when you are developing a plugin/component to let know with which version of the “main” package your plugin/component is supposed to work with (eg: React 16) peerDependencies :您的项目/包需要协同工作(与它们“合作”)或作为基础的包,主要在您开发插件/组件时有用,以便了解您的插件使用哪个版本的“主”包/component 应该可以使用(例如:React 16)
The difference between these two is that devDependencies are modules that are only required during development , while dependencies are modules that are also required at runtime .这两者之间的区别在于devDependencies是仅在开发期间需要的模块,而依赖项是在运行时也需要的模块。
To save a dependency as a devDependency on installation we need to do an #npm install --save-dev , instead of just an #npm install --save要在安装时将依赖项保存为 devDependency,我们需要执行#npm install --save-dev ,而不仅仅是#npm install --save
A nice shorthand for installing a devDependency that I like to use is #npm i -D .安装我喜欢使用的 devDependency 的一个很好的简写是#npm i -D 。 The shorthand for saving a regular dependency is -S instead of -D.保存常规依赖项的简写是 -S 而不是 -D。
Some good examples of dependencies that would be required at runtime include React, Redux, Express, and Axios .运行时需要的一些很好的依赖关系示例包括React、Redux、Express 和 Axios 。
Some good examples of when to install devDependencies would be Nodemon, Babel, ESLint, and testing frameworks like Chai, Mocha, Enzyme, etc…何时安装 devDependencies 的一些很好的例子是Nodemon、Babel、ESLint 和测试框架,如 Chai、Mocha、Enzyme 等……
When using Webpack to bundle a frontend application, the distinction between dependencies and devDependencies is not so clear.使用 Webpack 捆绑前端应用程序时,依赖项和 devDependencies 之间的区别不是很清楚。 For the final bundle, it doesn't matter where you place the dependencies (but it may be important for other tools).对于最终的捆绑包,放置依赖项的位置无关紧要(但对于其他工具可能很重要)。 That's why the documentation seems confusing.这就是文档看起来令人困惑的原因。
I found the explanation here: Do "dependencies" and "devDependencies" matter when using Webpack?我在这里找到了解释: Do "dependencies" and "devDependencies" when using Webpack?
需要依赖项才能运行,devDependencies 仅用于开发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.