What does 'invalid' mean when using npm list?

≡放荡痞女 提交于 2019-12-03 04:12:11

I was getting this error having the same package installed both in "dependencies" and "devDependencies" with different versions.

Ravi

It means that something depends on, for example, "async":"0.9.3" but when they do require("async"), npm thinks that they'll get some other version. And also check that the dependencies and their versions listed in your package.json file are available.

If everything is right then you can solve this problem with

npm update 

followed by

npm install.

I was getting this error after installing a newer version of a module, without updating my package.json. So the package.json required the older version, while npm list was detecting a newer version in my node_modules directory.

Running the following command got me rid of the message.

npm install {required_module}@{new_version} --save

I was getting a related but different error (but ended up here, so I'm answering here) where after running npm update I'd get. (No such issue with npm install, fwiw)

myapp@1.0.0 /home/malcolm/myapp
├── beeminder@1.4.3  invalid

The beeminder package is one I maintain, so in my main app I had set its semver to latest. This seemed to work fine before, but I guess a newer version of npm doesn't like it.

I figured it was reasonable to just use ^1.4.3 because if I'm introducing new changes then I probably am changing my own code anyway. But if for some weird reason you need the latest latest of a package (including breaking changes!) then you can use >= as a prefix instead of ^.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!