2

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

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I had to delete my node_modules and package-lock.json as well before I started since I was getting the same error when running npm update semver.
Okay, apparently that was a little premature. Tried downgrading node to 14 and 16 as well but that neither didn't work. Eventually found out my package-lock contains ^ versions, which it shouldn't. Removed them manually and now the install works fine. I have no clue how they got their, even with a clean install they still reappear...
3

Try this

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

And try npm install

1 Comment

That was something I had actually tried when I was having issues with this but didn't fix the problem. What worked was what I have put as an answer but maybe your answer will help someone else if they come across a similar problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.