npm install 未在新设备上完成

npm install is not completed on new device

我正在尝试将节点模块添加到项目中。在我的旧笔记本电脑上一切正常,没有发生错误。但是,在我的新 npm install 上无法正常工作。

我安装了node js,yarn,python3,通过安装程序修复了Node,还安装了windows构建工具npm install --global --production windows-build-tools@4.0.0,根据

这是我在 运行 npm install:

时得到的输出
C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex>npm i 
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm ERR! code 1
npm ERR! path C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
npm ERR! Build started 5/9/2022 4:25:56 PM.
npm ERR! Project "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
npm ERR! ValidateSolutionConfiguration:
npm ERR!   Building solution configuration "Release|x64".
npm ERR! Project "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.sln" (1) is building "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) on node 1 (default targets).
npm ERR! Project "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) is building "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\src\libsass.vcxproj" (3) on node 1 (default targets).
npm ERR! C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
npm ERR! Done Building Project "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\src\libsass.vcxproj" (default targets) -- FAILED.
npm ERR! Done Building Project "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.vcxproj.metaproj" (default targets) -- FAILED.
npm ERR! Done Building Project "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.sln" (default targets) -- FAILED.
npm ERR!
npm ERR! Build FAILED.
npm ERR!
npm ERR! "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.sln" (default target) (1) ->
npm ERR! "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\binding.vcxproj.metaproj" (default target) (2) ->
npm ERR! "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\src\libsass.vcxproj" (default target) (3) ->
npm ERR!   C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
npm ERR!
npm ERR!     0 Warning(s)
npm ERR!     1 Error(s)
npm ERR!
npm ERR! Time Elapsed 00:00:00.28
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\Program Files\nodejs\node.exe',
npm ERR! gyp verb cli   'C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-gyp\bin\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.15.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "C:\Users\savil\.windows-build-tools\python27\python.exe" in the PATH
npm ERR! gyp verb `which` succeeded C:\Users\savil\.windows-build-tools\python27\python.exe C:\Users\savil\.windows-build-tools\python27\python.exe
npm ERR! gyp verb check python version `C:\Users\savil\.windows-build-tools\python27\python.exe -c "import sys; print "2.7.15
npm ERR! gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 16.15.0
npm ERR! gyp verb command install [ '16.15.0' ]
npm ERR! gyp verb install input version string "16.15.0"
npm ERR! gyp verb install installing version: 16.15.0
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 16.15.0
npm ERR! gyp verb build dir attempting to create "build" dir: C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build
npm ERR! gyp verb build dir "build" dir needed to be created? C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\config.gypi
npm ERR! (node:19468) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp verb config.gypi checking for gypi file: C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "msvs"
npm ERR! gyp info spawn C:\Users\savil\.windows-build-tools\python27\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\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=2015',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-gyp\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\Users\savil\.node-gyp\16.15.0\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\savil\.node-gyp\16.15.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\Users\savil\.node-gyp\16.15.0\<(target_arch)\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\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\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp verb command build []
npm ERR! gyp verb build type Release
npm ERR! gyp verb architecture x64
npm ERR! gyp verb node dev dir C:\Users\savil\.node-gyp.15.0
npm ERR! gyp verb found first Solution file build/binding.sln
npm ERR! gyp verb could not find "msbuild.exe" in PATH - finding location in registry
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   '/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\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-gyp\lib\build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\savil\Desktop\Evonomix\morphyrichards-vtex\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.15.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\savil\AppData\Local\npm-cache\_logs22-05-09T13_25_42_191Z-debug-0.log

我通过 nvm(节点版本管理器)安装节点解决了我的问题。之后我切换到 Node 14,通过终端:

nvm install 14
nvm use 14