问题描述:
node 版本过低不能安装依赖,然后想着升级一下node版本之后,就应该变好了。???,事实好像并不是,输入npm -v 报错npm does not support Node.js v10.12.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
D:\Program Files\nodejs\node_global\node_modules\npm\lib\npm.js:32
#unloaded = false
^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
原因分析:
1.网上查了很多资料,node版本过高,npm不匹配了,运行报错
2.node官网查询对应的node版本和npm版本,但是记得之前未升级的npm版本和更新后的node版本是匹配的
3.敲黑板【!!!】npm缓存导致这步尤为重要,根据报错信息查看,果断删除报错对应的npm文件夹,不删除缓存,安装新的版本还是会出现npm报错
解决方案:
删除报错的文件夹下面的npm文件夹