简体   繁体   中英

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. eg if I installed express or gulp these plugins were added to dependencies automatically. But if I installed express-jwt or mongodb these plugins were not added

They are added to package.json when you append one of the following flags:

-S|--save|-D|--save-dev|-O|--save-optional

See https://docs.npmjs.com/cli/install for full documentation.

When you install a package with the --save or --save-dev flag, these are persisted to the dependencies or devDependencies arrays respectively.

If no flag is added, the package is downloaded but not persisted to 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.

If we use the following command to install npm dependencies-

npm install express-jwt --save or npm install mongodb --save

these installed dependencies will also be added to package.json file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM