[英]Automatically updating dependencies in package.json
I have one question I think is pretty simple. 我有一个问题我认为很简单。 Could you explain me why sometimes package.json is automatically updates and sometimes don't.
您能否解释一下为什么package.json有时会自动更新而有时却不会自动更新。 eg if I installed
express
or gulp
these plugins were added to dependencies automatically. 例如,如果我安装了
express
或gulp
这些插件会自动添加到依赖项中。 But if I installed express-jwt
or mongodb
these plugins were not added 但是,如果我安装了
express-jwt
或mongodb
则不会添加这些插件
They are added to package.json
when you append one of the following flags: 当您添加以下标志之一时,它们将添加到
package.json
:
-S|--save|-D|--save-dev|-O|--save-optional
See https://docs.npmjs.com/cli/install for full documentation. 有关完整的文档,请参见https://docs.npmjs.com/cli/install 。
When you install a package with the --save
or --save-dev
flag, these are persisted to the dependencies or devDependencies arrays respectively. 当安装带有
--save
或--save-dev
标志的软件包时,它们将分别持久保存到dependencies或devDependencies数组中。
If no flag is added, the package is downloaded but not persisted to package.json 如果未添加标志,则将下载软件包,但不会将其持久保存到package.json
Edit: There's is also the more obscure --save-optional flag, but it'd say it's mostly out of scope for this particular case. 编辑:还有一个更晦涩的--save-optional标志,但是对于这种特殊情况,它会超出范围。
If we use the following command to install npm dependencies- 如果我们使用以下命令安装npm依赖项-
npm install express-jwt --save or npm install mongodb --save npm install express-jwt --save或npm install mongodb --save
these installed dependencies will also be added to package.json file. 这些已安装的依赖项也将添加到package.json文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.