The commands npm add and npm install --save are often confusing in the context of npm (Node Package Manager). In fact, the npm add command is not part of npm's official command set; you might be referring to npm install or npm install --save. In early versions of npm, when you run npm install <package_name>, the package is installed into the project but is not automatically added to the dependencies section of the package.json file. To have the package added to dependencies, you need to explicitly use the --save option, such as npm install <package_name> --save. However, starting from npm 5.0.0, this behavior has changed. Now, when you run npm install <package_name>, the package is automatically added to the dependencies section of the package.json file by default. Therefore, the --save option is no longer necessary as it is now the default behavior. To summarize, initially npm install and npm install --save differed primarily in whether dependencies were automatically saved to the package.json file. However, starting from npm 5.0.0, these two commands have no functional difference because --save has become the default behavior.
Difference between 'npm add' and 'npm install -- save '?
1个答案
1
2024年6月29日 12:07 回复