正常情况下,npm可以直接运行
sudo npm install -g npm@xxx
但是大概是因为版本太低或者node用了n进行了多版本控制,导致升级一直error,出现了以下的问题
npm WARN npm npm does not support Node.js v18.20.0
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 4, 6, 7, 8, 9.
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:
可以直接运行
curl https://www.npmjs.com/install.sh | sudo sh
会自动将npm升级到目前最新版本