node.js 使用 npm list 时“无效”是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25696584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does 'invalid' mean when using npm list?
提问by user2229167
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 :
我是 nodejs 的新手,我刚刚在全球安装了 bower 模块。从那时起, npm list 命令给出了我在网上搜索但找不到任何帮助的以下输出:
**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?
其余输出正常,并列出已安装的模块。任何人都可以解释发生了什么?
回答by aaaristo
I was getting this error having the same package installed both in "dependencies" and "devDependencies" with different versions.
我在不同版本的“依赖项”和“devDependencies”中安装了相同的软件包时出现此错误。
回答by 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.jsonfile are available.
例如,这意味着某些东西取决于,"async":"0.9.3"但是当他们这样做时require("async"),npm 认为他们会得到一些其他版本。还要检查package.json文件中列出的依赖项及其版本是否可用。
If everything is right then you can solve this problem with
如果一切正常,那么你可以解决这个问题
npm update
followed by
其次是
npm install.
回答by Edo
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 listwas detecting a newer version in my node_modulesdirectory.
安装较新版本的模块后,我收到此错误,但没有更新我的 package.json。所以 package.json 需要旧版本,同时npm list在我的node_modules目录中检测到新版本。
Running the following command got me rid of the message.
运行以下命令让我摆脱了这条消息。
npm install {required_module}@{new_version} --save
npm install {required_module}@{new_version} --save
回答by MalcolmOcean
I was getting a related but different error (but ended up here, so I'm answering here) where after running npm updateI'd get. (No such issue with npm install, fwiw)
我遇到了一个相关但不同的错误(但最终在这里,所以我在这里回答)运行后npm update我会得到。(没有这样的问题npm install,fwiw)
[email protected] /home/malcolm/myapp
├── [email protected] invalid
The beeminderpackage 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 npmdoesn't like it.
这个beeminder包是我维护的,所以在我的主应用程序中,我将其 semver 设置为latest. 以前这似乎工作正常,但我想较新版本的npm不喜欢它。
I figured it was reasonable to just use ^1.4.3because 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 ^.
我认为只使用它是合理的,^1.4.3因为如果我要引入新的更改,那么我可能正在更改我自己的代码。但是,如果出于某种奇怪的原因您需要最新的包(包括重大更改!),那么您可以将其>=用作前缀而不是^.

