[Front-end] Differences between npm install --save, --save-dev, -D, -S, and -g


Preface

  • What is npm?

npm, the full name is Node Package Manager
npm is the package management tool for Node.js, used to install various Node.js extensions.

npm is a package management tool for JavaScript and the largest software registry in the world. There are over 600,000 JavaScript packages available for download, and they are downloaded approximately 3 billion times each week. npm makes it easy for JavaScript developers to use code shared by other developers.


1. Specific steps

The idea of ​​NPM is roughly this:

  1. Buy a server as a code repository (registry) and put all the code that needs to be shared in it

  2. Send an email to notify the author of jQuery, Bootstrap, and Underscore. Use npm publish to submit the code to the registry, and name it respectively jquery, bootstrap, and underscore (note the case)

  3. If other people in the community want to use these codes, they can write jquery, bootstrap and underscore into package.json, then run npm install, and npm will download the code for them.

  4. The downloaded code appears in the node_modules directory and is ready for use.

These codes that can be used are called "packages", which is where the name NPM comes from: Node Package Manager.

2. devDependencies and dependencies nodes

Dependency declaration
is to facilitate the installation of required dependencies for the project.

1. Use of devDependencies development environment

For example, gulp used in the project compresses CSS and JS modules. These modules are not needed after our project is deployed, so we can
install them using npm install -save-dev.

2. dependencies used in production environment

Modules like express jquery are necessary for the project to run.

Insert image description here

References

https://zhuanlan.zhihu.com/p/199022852

Guess you like

Origin blog.csdn.net/weixin_44625361/article/details/130358413