What does 'invalid' mean when using npm list?
Asked Answered
I

5

61

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: [email protected] /usr/local/lib/node_modules/bower/node_modules/chalk  
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/bower/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex  
npm ERR! invalid: [email protected] /usr/local/lib/node_modules/bower/node_modules/update-notifier/node_modules/configstore  
npm ERR! invalid: [email protected] /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: [email protected] /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: [email protected] /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?

Interpellate answered 6/9, 2014 at 3:49 Comment(1)
Check this answer. I had the same problem and this fixed. #25239044Ramtil
U
53

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

Uranic answered 5/9, 2016 at 12:33 Comment(0)
T
21

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.
Trakas answered 10/9, 2014 at 8:19 Comment(3)
Could you elaborate on your answer? If somelib's package.json depends on "async":"0.9.3", surely npm should install async 0.9.3 into somelib/node_modules and require("async") should load up async 0.9.3. Could you let us know the kinds of circumstances it would load up a different version of async? Not doubting the helpfullness of your answer, I just don't fully understand.Nations
@Nations somelib's package.json will always install the module version mentioned in somelib's package.json locally to that module. So, it will not cause any problems for within the module. But in your project setup, if you have done something like npm install [email protected], and in your package.json you have specified dependency as async: 0.9.x then this case arises.Trakas
Ah. My project setup would normally just run npm install (without any options) and install whatever's in package.json because all dependencies should be in package.json (or the shrinkwrap file).Nations
H
10

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

Hallie answered 28/6, 2016 at 10:18 Comment(0)
U
4

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

├─┬ [email protected] invalid

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

Urbanism answered 5/2, 2021 at 21:3 Comment(0)
W
0

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)

[email protected] /home/malcolm/myapp
├── [email protected]  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 ^.

Will answered 25/5, 2016 at 18:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.