2013-10-12 21 views
152

私は 'yo angular'を実行し、後で1.0.8をインストールしたことを認識しました。角度コンポーネントをアンインストールしましたが、オリジナルのbower.jsonファイルは 'devDependencies' devDependenciesの代わりに、依存関係の下ですべての1.2.0-rc.2コンポーネントの角モックと角度シナリオを再追加します。BowerとdevDependenciesと依存関係

devDependenciesがどのように使用されているのか、手動で修正したり放置したりするのが気になります。 bower CLIで何かをdevの依存関係としてマークする方法を指定する方法はありますか?編集する前に

{ 
    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は、実運用には必須であり、開発者にも必要と想定されています。

devDependenciesdependenciesに含めると、それは有害ではありません。モジュールは、インストール中に多くのファイル(バイト)をバンドルするだけで、より多くの(不要な)リソースを消費します。純粋なPOVから、これらの余分なバイトは有害かもしれません、ちょうどあなたの視点に依存します。

いくつかの光を当てるために、bower help installを見て、devDependenciesの下にリストされたモジュールは、例えば、-pまたは--productionを経由して、モジュールのインストール時に省略することができます。

bower install angular-latest --production 

これは、他の何のためのインストールを実行するための推奨される方法です開発プラットフォームよりも優れています。

逆に、dependenciesにリストされているモジュールを省略することはできません。完全にクリア

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

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を参照してください):[email protected]bower latest sourceを参照)、bower help利回りのよう


それをアップ。ありがとうございます。 – Gary

+0

は、bower.jsonから不要なdepsを削除したときに自動削除されるようにするための方法ですか? – FutuToad

+1

@FutuToad、私はそれを試したことはありませんが、 'bower update'(古いデップを削除した最新バージョンを入手する)と' bower prune'(余分なローカルパッケージを削除する)がこのトリックを行うかもしれません。 – zamnuts

関連する問題