npm install 报错WARNING: You are likely using a version of node-tar or npm that is incompatible with

运行vue项目,npm install时报错如下

WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
npm[15808]: src\node_zlib.cc:460: Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
 1: 00007FF753D7ABAA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810
 2: 00007FF753D20C96 uv_loop_fork+80486
 3: 00007FF753D20D4F uv_loop_fork+80671
 4: 00007FF753CAAAAD v8::internal::LookupIterator::index+94221
 5: 00007FF75418367E v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+59870
 6: 00007FF754184BE0 v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+65344
 7: 00007FF754183B79 v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+61145
 8: 00007FF754183A5B v8::internal::interpreter::HandlerTableBuilder::HandlerTableBuilder+60859
 9: 0000030D82050361

npm install 报错WARNING: You are likely using a version of node-tar or npm that is incompatible with_第1张图片
我用的是nvm版本管理工具
npm默认5.4.0,node版本用的是11.2.0
出错原因是,node版本和npm版本不匹配

解决方法:卸载nvm默认自带的 npm5.4.0

npm uninstall -g npm

nvm版本管理工具自带npm5.4.0与node版本不匹配,所以**一定要先卸载npm5.4.0**,
当你卸载npm5.4.0后,会自动变成npm6.4.1。因为之前安装node11.2.0自动捆绑对应npm6.4.1。

不能直接升级npm版本(亲测无效)
npm install 报错WARNING: You are likely using a version of node-tar or npm that is incompatible with_第2张图片
即可运行vue项目
npm install 报错WARNING: You are likely using a version of node-tar or npm that is incompatible with_第3张图片
npm install 报错WARNING: You are likely using a version of node-tar or npm that is incompatible with_第4张图片
大功告成

你可能感兴趣的:(bug,vue.js,npm,前端)