1. 升级npm至最新版本
npm install -g npm
2. 报错npm WARN saveError ENOENT: no such file or directory, open '/xxx/.npm/_logs/package.json'
解决办法:找不到package.json文件,则执行
npm init -y 自动默认配置项
3. 报错npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "npm:": npm:string-width@^4.2.0
解决办法:执行手动安装string-width
npm install string-width@^4.2.0 --registry=https://registry.npmjs.org/
4. 手欠单独升级了npm到最新版本,导致和node版本不兼容,报错:
解决办法:
安装nodejs的版本管理工具nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
安装nodejs指定版本
nvm install 16.13.0
至此解决