Previously struggled with the issue of package dependency management for an npm installation. That is true:
When we use npm install to install modules or plugins, there are two commands to write them into the package.json file, they are:
--save-dev
or
--save
First of all, it should be noted that the Chinese meaning of the word Dependencies means dependency and dependency, while dev is
Short for develop.
Therefore, the difference between them is reflected in the package.json file, which is that plugins installed using --save-dev are written to the devDependencies domain, while plugins installed using --save are written to the dependencies block.
So what's the difference between devDependencies and dependencies objects in package.json files?
The plugins in devDependencies are only used in the development environment, not in the production environment, and dependencies need to be released to the production environment.
For example, if we write a project that depends on jQuery, an error will be reported if the dependency runs without this package, so we will write this dependency to dependencies.
And some of the build tools we use, such as glup and webpack, are just packages used in development, and they are online
It has nothing to do with them, so write it to devDependencies.
|