lross15
lross15

Reputation: 177

Npm install fails due to invalid version

So as part of some work I'm doing, I am trying to get the packages we use in our application up to the latest versions as when running npm audit there were a significant amount of vulnerabilities.

One of the the things it comes up saying to install [email protected]

I have been trying to do this but I get an error saying:

npm ERR! Invalid version: ^6.0.1

I have no idea what this is referring to as in the package.json there are no packages that have this version and when I look at the debug log I just get:

207 verbose stack TypeError: Invalid Version: ^6.0.1
207 verbose stack     at new SemVer (C:\Program Files\nodejs\node_modules\npm\node_modules\semver\classes\semver.js:38:13)
207 verbose stack     at compare (C:\Program Files\nodejs\node_modules\npm\node_modules\semver\functions\compare.js:3:32)
207 verbose stack     at Object.gte (C:\Program Files\nodejs\node_modules\npm\node_modules\semver\functions\gte.js:2:30)
207 verbose stack     at CanPlaceDep.checkCanPlaceCurrent (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\can-place-dep.js:173:51)
207 verbose stack     at CanPlaceDep.checkCanPlace (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\can-place-dep.js:157:27)
207 verbose stack     at new CanPlaceDep (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\can-place-dep.js:114:26)
207 verbose stack     at PlaceDep.place (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:121:19)
207 verbose stack     at new PlaceDep (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\place-dep.js:71:10)
207 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:949:31
207 verbose stack     at Array.map (<anonymous>)
208 verbose cwd C:\tfs\Agility\Branches\AgilityMakeover\Client\Web\AgilityItemViewer
209 verbose Windows_NT 10.0.19044
210 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]"
211 verbose node v16.14.0
212 verbose npm  v8.3.1
213 error Invalid Version: ^6.0.1
214 verbose exit 1

So I have no idea what this could be referring to, as far as I can tell there is no package reference. I have tried just removing the package-lock.json file and the deleting the node_modules folder and running npm install again but I keep getting this error. But I have no clue on how to progress, any advice would be appreciated

Upvotes: 2

Views: 11276

Answers (2)

Abraham
Abraham

Reputation: 15840

Try this

  • Delete npm_modules folder
  • Delete the package.json.lock file
  • run npm cache clean --force

And try npm install

Upvotes: 2

lross15
lross15

Reputation: 177

What eventually seemed to solve the problem for me was going through the list of packages shown i.e semver, can-place-dep etc and updating them all manually by doing: npm update semver and so on. I then deleted my package-lock.json and node_modules folder again and did npm install. After this I stopped getting the invalid version error. Hopefully this can help someone else if they end up having the same issue I had

Upvotes: 4

Related Questions