简体   繁体   中英

Exclude NPM packages from update

I'm using npm for my React Native project and i'm trying to ignore few packages during npm update .

For example, i want to keep my React package always on react@16.3.1 . But each time i run npm update it gets updated to react@16.4.1 .

Any ideas how could i do that?

Thanks in advance for any help.

In your package.json file use "react": "~16.3.1" instead of "react": "^16.3.1" ie replace caret (which means equals or higher version) with tilda.

EDIT: @Gabriel Carnerio's point is valid. Tilda is for when minor version changes are ok. Remove it and use "react": "16.3.1" if you want exact v16.3.1

It behaves depending on the Semantic Versioning of the NPM. Inside dependencies of your package.json file if the react version is specified as "react": "16.3.1", then your react version will not get updated.

Just change the package.json .

Where is:

{
  "dependencies": {
    "react": "^16.3.1"
  }
}

Change to:

{
  "dependencies": {
    "react": "16.3.1"
  }
}

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