What does 'invalid' mean when using npm list?

node.jsNpmBower

node.js Problem Overview


I am new to nodejs and i had just installed bower module globally. Ever since then, npm list command gives the following output which I searched for on the web but couldn't find any help :

**npm ERR! invalid: chalk@0.5.1 /usr/local/lib/node_modules/bower/node_modules/chalk  
npm ERR! invalid: ansi-regex@0.2.1 /usr/local/lib/node_modules/bower/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex  
npm ERR! invalid: configstore@0.3.1 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/configstore  
npm ERR! invalid: object-assign@0.3.1 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/object-assign  
npm ERR! invalid: registry-url@0.1.1 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url  
npm ERR! invalid: strip-ansi@0.2.2 /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/string-length/node_modules/strip-ansi  
npm ERR! not ok code 0**

The rest of the output is normal and lists the installed modules. Can anyone explain what's going on?

node.js Solutions


Solution 1 - node.js

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

Solution 2 - node.js

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.

Solution 3 - node.js

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

Solution 4 - node.js

Simplest answer

This can arise when the installed version of a package does not correspond to what package.json would install.

Example

Say you have specified "axios": "0.19.2", in your package.json, but after that you would install a specific version using npm install [email protected].

An npm list | grep axios would now yield

├─┬ axios@0.18.1 invalid

Follow the instructions in this answer on how to fix it.

Solution 5 - node.js

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 ^.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2229167View Question on Stackoverflow
Solution 1 - node.jsaaaristoView Answer on Stackoverflow
Solution 2 - node.jsRaviView Answer on Stackoverflow
Solution 3 - node.jsEdoView Answer on Stackoverflow
Solution 4 - node.jsPax VobiscumView Answer on Stackoverflow
Solution 5 - node.jsMalcolmOceanView Answer on Stackoverflow