What is the difference between --save and --save-dev?

后端 未结 13 887
旧巷少年郎
旧巷少年郎 2020-11-28 00:02

What is the difference between:

npm install [package_name]

and:

npm install [package_name] --save

and:

13条回答
  •  孤独总比滥情好
    2020-11-28 00:25

    I want to add some my ideas as

    I think all differents will appear when someone use your codes instead of using by yourself

    For example, you write a HTTP library called node's request

    In your library,

    you used lodash to handle string and object, without lodash, your codes cannot run

    If someone use your HTTP library as a part of his codes. Your codes will be compiled with his.

    your codes need lodash, So you need put in dependencies to compile


    If you write a project like monaco-editor, which is a web editor,

    you have bundle all your codes and your product env library using webpack, when build completed, only have a monaco-min.js

    So someone don't case whether --save or --save-dependencies, only he need is monaco-min.js

    Summary:

    1. If someone want to compile your codes (use as library), put lodash which used by your codes into dependencies

    2. If someone want add more feature to your codes, he need unit test and compiler, put these into dev-dependencies

提交回复
热议问题