2013-10-12 192 views
152

我跑「喲角」,後來意識到它安裝1.0.8,我卸載了角分量,但是原來的bower.json文件有角嘲笑和角度的場景下「devDependencies」時我重新添加所有的1.2.0-rc.2組件angular-mocks和angular-scenario,而不是devDependencies。鮑爾和devDependencies VS依賴

我很好奇,devDependencies是如何使用的,如果我要費心手動修復它,也就是我們離開。有沒有一種方法可以在bower CLI上指定如何將某些東西標記爲開發依賴項?

後編輯文件:

{ 
    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" 
    } 
} 

回答

267

devDependencies是與發展有關的腳本,例如單元測試,封裝腳本,文檔生成等

dependencies所需的生產使用,並且假設需要dev的爲好。

包括devDependenciesdependencies之內,因爲你擁有它,不會有害;該模塊將在安裝過程中捆綁更多文件(字節) - 消耗更多(不必要)的資源。從純粹的POV,這些額外的字節可能是有害的,只取決於你的觀點。

爲了闡明一些,看着bower help installdevDependencies下所列模塊可在模塊安裝期間通過-p--production,可以省略例如:

bower install angular-latest --production 

這是爲了執行安裝用於任何其他的推薦的方法而不是一個開發平臺。

相反,沒有辦法省略dependencies下列出的模塊。


作爲[email protected](見bower latest source),bower help產量:

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. 

和進一步,bower help install產率(見latest source):

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. 
+0

即完全清除它起來。非常感謝 – Gary

+0

有沒有一種方法可以在你從bower.json中刪除它們時自動刪除不需要的代碼? – FutuToad

+1

@FutuToad,我還沒有嘗試過,但一個'涼亭update'(以獲取最新版本刪除舊的DEPS),後跟一個'涼亭prune'(刪除多餘的本地包)可能做的伎倆。 – zamnuts