vue npm install 出现报错

743 阅读2分钟

我平时使用yarn偏多一点。最近想要使用一个插件但是不能使用yarn去安装,只能使用npm去安装。就想npm install 一下。但是 npm install 一直报错,来记录一下以下是报错过程和解决方法。

npm ERR! code 1
npm ERR! path C:\Users\flex_gap\Desktop\myproject\allinone\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! �ڴ˽��������һ������һ����Ŀ����Ҫ���ò������ɣ������ӡ�/m�����ء�
npm ERR! MSBUILD : error MSB4132: �޷�ʶ�𹤾߰汾��2.0�������õĹ��߰汾Ϊ "4.0"��
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@14.15.3 | win32 | x64
npm ERR! gyp info spawn D:\Projects\python27\python.EXE
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-G',
npm ERR! gyp info spawn args   'msvs_version=auto',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-sass\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\flex_gap\\.node-gyp\\14.15.3\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\flex_gap\\.node-gyp\\14.15.3',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-sass',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-sass\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
npm ERR! Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
npm ERR! Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
npm ERR! Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
npm ERR! gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\flex_gap\Desktop\myproject\allinone\node_modules\node-gyp\lib\build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "D:\\Env\\nodejs\\node.exe" "C:\\Users\\flex_gap\\Desktop\\myproject\\allinone\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\flex_gap\Desktop\myproject\allinone\node_modules\node-sass
npm ERR! gyp ERR! node -v v14.15.3
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\flex_gap\AppData\Local\npm-cache\_logs\2022-01-22T01_47_26_936Z-debug-0.log

百度了一大堆才找到解决方案, 在C盘/用户(user) 下找到文件 .yarnrc.npmrc 将其删除

npm install 报错.png

我报错的罪魁祸首就是这个,将其直接干掉就好了