因为本地运行不同的项目需要的node.js版本不一样,所以经常需要用nvm来切换nodejs版本,有时候下载依赖就会出现问题。 想下载依赖 运行npm i 后报错,提示node和npm 版本不对应:
npm does not support Node.js v14.15.1 ...
解决思路:
1.考虑node版本和npm版本不兼容的问题,查看node对应的npm版本,发现版本确实有问题 地址:https://nodejs.org/zh-cn/download/releases 2.更新npm版本npm install -g [email protected]3.下载npm对应版本之后提示失败,上网搜查后发现可能是因为旧的npm包缓存的问题导致下载失败
npm npm does not support Node.js v14.15.1 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11. npm WARN npm You can find the latest version at https://nodejs.org/ npm ERR! cb.apply is not a function npm ERR! A complete log of this run can be found in: npm ERR! D:\softwares\node-v14.15.1-win-x64\node-cache\_logs\2023-07-29T15_37_29_641Z-debug.log
4.删除node缓存, node_global和node_cache目录下的所有东西
5.重新执行第3步中的命令,这次成功更新npm版本,查看npm也没有报错npm install -g [email protected]
npm -v 6.14.156.重新下载依赖,成功下载依赖,项目成功运行
npm i
标签:npm,Node,node,js,报错,版本,下载 From: https://www.cnblogs.com/jjSmileEveryDay/p/17592296.html