【发布时间】:2020-03-17 01:14:50
【问题描述】:
如果 nodejs 和特别是 node-gyp 不依赖于它,我根本不会使用 Visual Studio。我真正想做的就是安装 active-win npm 包,但因为它有一个窗口 API 依赖项,我需要运行 node-gyp,这让我掉进了这个兔子洞。
无论出于何种原因,2015 年的 Visual Studio 安装程序崩溃,但我只是使用了npm install --global --production windows-build-tools。它成功安装了构建工具,但是这里的问题仍然存在。
这也是一个较小的错误,尽管 msmversion 设置为 2015,但 node-gyp 尝试在 /v120/ 中查找,我通过设置 VCTargetsPath 位置解决了这个问题。
这是此时运行 npm i -D active-win 的完整错误:
C:\Users\Henry Hunt\Documents\GitRep\ludite>npm install -D active-win
> iconv@2.3.5 install C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\iconv
> node-gyp rebuild
C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\iconv>if not defined npm_config_node_gyp (node "N:\Nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "N:\Nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\iconv\build\iconv.vcxproj(20,3): error MSB4019: The imported p
roject "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Default.props" was not found. Confirm that
the path in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (N:\Nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "N:\\Nodejs\\node.exe" "N:\\Nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\iconv
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
> ref-napi@1.4.2 install C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\ref-napi
> node-gyp rebuild
C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\ref-napi>if not defined npm_config_node_gyp (node "N:\Nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "N:\Nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\ref-napi\node_modules\node-addon-api\src\nothing.vcxproj(20,3)
: error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Default.pro
ps" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (N:\Nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "N:\\Nodejs\\node.exe" "N:\\Nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Henry Hunt\Documents\GitRep\ludite\node_modules\ref-napi
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN @date-io/date-fns@1.3.11 requires a peer of date-fns@2.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN extract-text-webpack-plugin@3.0.2 requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iconv@2.3.5 (node_modules\iconv):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: iconv@2.3.5 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ref-napi@1.4.2 (node_modules\ref-napi):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ref-napi@1.4.2 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ active-win@6.0.0
added 2 packages from 3 contributors, updated 1 package and audited 10413 packages in 6.338s
found 0 vulnerabilities
安装的构建工具的版本是 2015 并且其进入 \V140\ 的文件夹实际上是配置似乎存储的位置。缺少的一个文件是 Microsoft.Cpp.Default.props。我一直找不到遇到同样问题的人。有很多人有同样的错误,但在解决他们的问题时,Microsoft.Cpp.Default.props 只是在其他目录中。这是它应该在的目录,它不存在。
我该如何解决这个问题?
【问题讨论】:
-
更新:我已经安装了 Visual Studio 2019 并开始使用该安装而不是 npm install_build_tools 版本。在设置 npm config 的 msvs_version = "2019" 和 msbuild_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" 大多数我的问题已经解决了。
-
运行 npm 重建
-
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.ToolsetLocation.props(50,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\ Microsoft\VC\v160Platforms\x64\Platform.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\Users\henhen724\Documents\GitRep\ludite\node_modules\iconv\build\iconv.vcxpr oj] gyp ERR! build error -
用任何寄存器存储的话 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\ Microsoft\VC\v160 缺少\,这似乎是唯一的事情阻止它运行。