Bower和devDependencies与依赖关系 [英] Bower and devDependencies vs dependencies
问题描述
我运行了 yo angular,然后意识到它安装了1.0.8,我卸载了angular组件,但是当我重新添加所有内容时,原始的bower.json文件在 devDependencies下有angular-mocks和angular-scenario。 1.2.0-rc.2组件在依存关系而不是devDependencies下的angular-mocks和angular-scenario。
I ran 'yo angular' and realized afterwards that it installs 1.0.8, I uninstalled the angular components, however the original bower.json file had angular-mocks and angular-scenario under 'devDependencies' when I re-add all the 1.2.0-rc.2 components angular-mocks and angular-scenario under dependencies instead of devDependencies.
我很好奇如何使用devDependencies,以及是否使用devDependencies应该麻烦手动修复它或保持原样。有没有一种方法可以在Bower CLI中指定如何将某些内容标记为开发依赖项?
I'm curious as to how devDependencies is used and if I should bother manually fixing it or leave as is. Is there a way to specify on the bower CLI how to mark something as a dev dependency?
编辑文件后:
{
name: "Angular",
version: "0.0.0",
dependencies: {
json3: "~3.2.4",
jquery: "~1.9.1",
bootstrap-sass: "~2.3.1",
es5-shim: "~2.0.8",
angular-mocks: "1.2.0-rc.2",
angular-sanitize: "1.2.0-rc.2",
angular-resource: "1.2.0-rc.2",
angular-cookies: "1.2.0-rc.2",
angular: "1.2.0-rc.2",
angular-scenario: "1.2.0-rc.2"
},
devDependencies: { }
}
修改前:
{
"name": "Angular",
"version": "0.0.0",
"dependencies": {
"angular": "~1.0.7",
"json3": "~3.2.4",
"jquery": "~1.9.1",
"bootstrap-sass": "~2.3.1",
"es5-shim": "~2.0.8",
"angular-resource": "~1.0.7",
"angular-cookies": "~1.0.7",
"angular-sanitize": "~1.0.7"
},
"devDependencies": {
"angular-mocks": "~1.0.7",
"angular-scenario": "~1.0.7"
}
}
推荐答案
devDependencies
用于与开发相关的脚本,例如单元测试,打包脚本,文档生成等。
devDependencies
are for the development-related scripts, e.g. unit testing, packaging scripts, documentation generation, etc.
依赖项
对于生产用途是必需的,并假定为
dependencies
are required for production use, and assumed required for dev as well.
包括在依赖项
内的 devDependencies
,只要有,就不会有害;该模块将在安装过程中捆绑更多文件(字节),从而消耗更多(不必要的)资源。从纯粹的POV来看,这些额外的字节可能是有害的,仅取决于您的观点。
Including devDependencies
within dependencies
, as you have it, won't be harmful; the module will just bundle more files (bytes) during the install - consuming more (unnecessary) resources. From a purist POV, these extra bytes could be detrimental, just depends on your perspective.
为了阐明一些内容,请查看 bower help install
,在 devDependencies
下列出的模块可以在安装过程中通过 -p
或<$省略c $ c>-生产,例如:
To shed some light, looking at bower help install
, modules listed under devDependencies
can be omitted during the module installation via -p
or --production
, e.g.:
bower install angular-latest --production
这是对开发平台以外的其他设备执行安装的推荐方法。
This is the recommended way to perform an installation for anything other than a development platform.
相反,无法忽略依赖项
下列出的模块。
On the contrary, there is no way to omit modules listed under dependencies
.
截至 bower@1.2.7 (请参见提供最新信息),提供帮助
的结果:
As of bower@1.2.7 (see bower latest source), bower help
yields:
Usage:
bower <command> [<args>] [<options>]
Commands:
cache Manage bower cache
help Display help information about Bower
home Opens a package homepage into your favorite browser
info Info of a particular package
init Interactively create a bower.json file
install Install a package locally
link Symlink a package folder
list List local packages
lookup Look up a package URL by name
prune Removes local extraneous packages
register Register a package
search Search for a package by name
update Update a local package
uninstall Remove a local package
Options:
-f, --force Makes various commands more forceful
-j, --json Output consumable JSON
-l, --log-level What level of logs to report
-o, --offline Do not hit the network
-q, --quiet Only output important information
-s, --silent Do not output anything, besides errors
-V, --verbose Makes output more verbose
--allow-root Allows running commands as root
See 'bower help <command>' for more information on a specific command.
进一步,更高的帮助安装量
参见最新来源):
Usage:
bower install [<options>]
bower install <endpoint> [<endpoint> ..] [<options>]
Options:
-F, --force-latest Force latest version on conflict
-h, --help Show this help message
-p, --production Do not install project devDependencies
-S, --save Save installed packages into the project's bower.json dependencies
-D, --save-dev Save installed packages into the project's bower.json devDependencies
Additionally all global options listed in 'bower help' are available
Description:
Installs the project dependencies or a specific set of endpoints.
Endpoints can have multiple forms:
- <source>
- <source>#<target>
- <name>=<source>#<target>
Where:
- <source> is a package URL, physical location or registry name
- <target> is a valid range, commit, branch, etc.
- <name> is the name it should have locally.
这篇关于Bower和devDependencies与依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!