4

Let's say my package.json looks like this:

{
  "name": "cool_project",
  "version": "0.0.0",
  "scripts": {
    "start": "node index.js"
  },
  "private": true,
  "dependencies": {
    "rxjs": "^6.0.0"
  }
}

And then after running npm install the version of rxjs version is 6.6.0.

npm ls rxjs
`-- rxjs@6.6.0

Is there an npm or yarn command I can now run to pin the version inside my package.json to the version installed?

{
  "name": "cool_project",
  "version": "0.0.0",
  "scripts": {
    "start": "node index.js"
  },
  "private": true,
  "dependencies": {
    "rxjs": "6.6.0"
  }
}

This is useful for me because if I want to check what package versions I'm on, I can easily see it directly inside of package.json and commit it to my git repo history.

strider
  • 5,674
  • 4
  • 24
  • 29
petur
  • 1,366
  • 3
  • 21
  • 42

1 Answers1

-1

1) Change every version in package.json to *

2) run npm install --save-exact

Shubham
  • 1,288
  • 2
  • 11
  • 32