简体   繁体   English

npm 与 Node.js 不兼容

[英]npm is not compatible with Node.js

I had node installed in my machine and everything was working fine.我的机器上安装了节点,一切正常。 During an online course made in 2019, the instructor was using an earlier version of npm (v5.5.1) and advised everyone to use the same version with him for follow up reasons.在 2019 年的在线课程中,讲师使用的是较早版本的 npm (v5.5.1),并建议大家使用与他相同的版本,以便跟进。 So I downgraded to v5.5.1 but now I keep getting one same error (incompatibility) for almost all commands.所以我降级到v5.5.1,但现在几乎所有命令都出现相同的错误(不兼容)。 I read some solutions to similar problems here and even tried extra steps but the problem still persists.我在这里阅读了一些类似问题的解决方案,甚至尝试了额外的步骤,但问题仍然存在。 I uninstalled node from my system, restarted the system and reinstalled node but the version of npm still remained v5.5.1 .我从我的系统中卸载了 node,重新启动了系统并重新安装了 node,但 npm 的版本仍然是v5.5.1 I tried to uninstall npm from the command line npm uninstall -g npm but it threw incompatibility error.我试图从命令行npm uninstall -g npm但它引发了不兼容错误。 I searched the web for compatible version of node.js for npm v5.5.1 and got node v10.15.1 which I downloaded installed with several system restarts but my node and npm still remain incompatible.我在网络上搜索了 npm v5.5.1 的兼容版本的 node.js 并获得了我下载的 node v10.15.1 ,并在多次系统重启时安装了它,但我的 node 和 npm 仍然不兼容。 Please what can I do?请问我能怎么办?

You should use nvm which is the Node Version Manager , cURL:您应该使用nvm这是节点版本管理器,cURL:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

commands:命令:

nvm install <version>       Download and install a <version>
nvm use <version>           Modify PATH to use <version>
nvm ls                      List versions (installed versions are blue)

Helpful reads:有用的阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM