0

We have following requirements in our package.json,

"three-orbitcontrols": "^2.102.2"

in one computer, node_modules/three-orbigcontrols/package.json has

   "_from": "three-orbitcontrols@2.102.2",
   "_id": "three-orbitcontrols@2.102.2",

in another computer,

   "_from": "three-orbitcontrols@2.102.2",
   "_id": "three-orbitcontrols@2.110.1",

So specifying ^2.102.2 doesn't force the version (2.110.1 is installed`

What's the correct way of specifying specific 2.102.2 ?

eugene
  • 39,839
  • 68
  • 255
  • 489
  • Have you tried adding the `--force` argument, i.e. running `npm install --force` - The `--force` argument forces npm to fetch remote resources even if a local copy exists on disk - perhaps it's installing a local copy ? – RobC Nov 25 '19 at 12:16
  • Actually, maybe I misread your question. Do you want the earlier version `2.102.2` to be installed on both computers and _not_ the latest, i.e. `2.110.1`. – RobC Nov 25 '19 at 12:22
  • yes I want 2.102.2 – eugene Nov 25 '19 at 12:36
  • Well I have no idea why one machine is ignoring the [caret range](https://stackoverflow.com/questions/22343224/whats-the-difference-between-tilde-and-caret-in-package-json) that you've specified in _package.json_, i.e. `"three-orbitcontrols": "^2.102.2"` - the `^` means that you should get version `2.110.1 ` on both machines. To get version `2.102.2` on both machines I'd try: **1)** Setting your _package.json_ to `"three-orbitcontrols": "2.102.2"` (Note: the caret has been deleted) **2)** Deleting the _node_modules_ directory on both machines. **3)** Then run `npm install` on both machines – RobC Nov 25 '19 at 12:51
  • btw. The online [semver calculator](https://semver.npmjs.com/) indicates that specifying `^2.102.2` for `three-orbitcontrols` should give you version `2.110.1`. – RobC Nov 25 '19 at 12:55
  • I think the machine had 2.102.2 because it was the latest by that time it was installed on the machine, and now it's not.. I just wanna fix it to specific version because their api changed from 2.102.2 and break things in 2.110.1 strangely.. – eugene Nov 25 '19 at 13:02
  • The version released after `2.102.2` was `2.108.1` , i.e. it was a [MINOR](https://semver.org/) release. In which case you can change the caret `^` to `~` , i.e. a [tilde range](https://docs.npmjs.com/misc/semver#tilde-ranges-123-12-1). So by changing your _package.json_ to `"three-orbitcontrols": "~2.102.2"`, deleting _node_modules_ and running `npm install` again it will give you `2.102.2 `. – RobC Nov 25 '19 at 13:24
  • so ^ should be backward compatible, and in this case, it is not somehow.. https://stackoverflow.com/a/31733623/433570, Thanks for help @RobC – eugene Nov 25 '19 at 13:59
  • If what is suggested in my last comment doesn't help, and you later discover that it's not actually the version of `three-orbitcontrols` that is causing the issue - but instead it's a dependency that `three-orbitcontrols` utilizes that's causing the issue. Then, I suggest **1)** Running [`npm shrinkwrap`](https://docs.npmjs.com/cli/shrinkwrap) in the project dir on the machine that everything works successfully. **2)** Copying the resultant `npm-shrinkwrap.json` file to the project folder on the machine that's not working -> deleting node_modules folder -> then running `npm install`. – RobC Nov 25 '19 at 14:02
  • aye I think I could handle it, thanks again.. – eugene Nov 25 '19 at 14:06

0 Answers0