npmnpm-installpackage.jsonpackage-lock.json

Is it safe to remove the caret in package.json?


I sometimes want to switch my projects to use exact package versions.

Current:

"dependencies": {
  "firebase": "^9.6.2",
  "next": "12.0.7",
  "react": "17.0.2",
  "react-dom": "17.0.2",
  "react-firebase-hooks": "^4.0.2",
  "react-firebaseui": "^6.0.0"
}

Is it safe to simply remove the carets in front of the package names?

Or do I need to first uninstall these packages and reinstall specifying the exact version?


Solution

  • You should look for the installed version with npm list, then fix that version in the package.json. That way you won't be changing any versions.