node.js 在 npm 包全局安装上获取“npm ERR!code EPEERINVALID”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33816824/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 19:33:14  来源:igfitidea点击:

Getting "npm ERR! code EPEERINVALID" on npm packages global install

node.jsnpmnode-modules

提问by Robins Gupta

Whenever I am installing any global package I am getting this error.

每当我安装任何全局包时,我都会收到此错误。

Error:- on npm packages global install

错误:- 在 npm 包全局安装上

For example:-

例如:-

robins@robins-H61MLV3:~$ sudo npm install -g jshint

/usr/bin/jshint -> /usr/lib/node_modules/jshint/bin/jshint
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "jshint"
npm ERR! node v0.10.25
npm ERR! npm  v2.13.2
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants karma@~0.10.0
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.12.8
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9
npm ERR! peerinvalid Peer [email protected] wants karma@>=0.9

What I have tried so far

到目前为止我尝试过的

I have tried updating the global karma and its related modules but it didn't worked. I have also tried uninstalling karma modules but the problem persists.

我曾尝试更新 global karma 及其相关模块,但没有奏效。我也尝试卸载 karma 模块,但问题仍然存在。

sudo npm uninstall -g  karma grunt-karma karma-html2js-preprocessor  karma-mocha karma-phantomjs-launcher karma-script-launcher  karma-jasmine  karma-requirejs karma-coffee-preprocessor

回答by Don

It looks like karma has some dependencies on other modules that are available (global), but are older. You'd need to update your global packages using npm update -g

看起来 karma 对其他可用(全局)但较旧的模块有一些依赖性。你需要使用 npm update -g 更新你的全局包

npm update -g

Basically "npm update -g" just updates all Global packages. "All" because no package name has been provided and "global" because of the "-g" switch.

基本上“npm update -g”只是更新所有全局包。“全部”是因为没有提供包名,“全局”是因为“-g”开关。

My suggestion is to first update all of your global packages and then try installing jshint again.

我的建议是首先更新所有全局包,然后再次尝试安装 jshint。

sudo npm install -g jshint

回答by Prashant

update npm by using command

使用命令更新 npm

npm install npm -g

then clean the cache using

然后使用清理缓存

npm cache clean

then install the package as per your requirement. Hope, this would help all.

然后根据您的要求安装软件包。希望,这会对所有人有所帮助。

回答by Tendai Katsande

I fixed the problem by just naming my project with a single word instead of a phrase that I had used before.

我通过只用一个词而不是我以前使用的短语来命名我的项目来解决这个问题。

回答by Elijah Lofgren

It's not a fix for NPM, but a workaround in my case (using Ubuntu 16.04) on this issue was to install yarn and run "yarn install" instead of "npm install".

这不是 NPM 的修复程序,但在我的情况下(使用 Ubuntu 16.04)解决此问题的方法是安装 yarn 并运行“yarn install”而不是“npm install”。