首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >所有visual studio安装程序崩溃和可视化构建工具也不能工作。

所有visual studio安装程序崩溃和可视化构建工具也不能工作。
EN

Stack Overflow用户
提问于 2019-11-21 07:17:17
回答 1查看 1.5K关注 0票数 2

如果nodejs,特别是node不依赖于nodejs,我根本不会在Visual上捣乱。我真正想要做的就是安装active-win npm包,但是因为它有一个窗口API依赖项,所以我需要运行node,这就让我掉进了这个兔子洞。

不管出于什么原因,2015年的visual安装程序都会崩溃,但我只是使用了npm install --global --production windows-build-tools。它成功地安装了构建工具,但是这里的问题依然存在。

这也是一个较小的错误,当节点-gyp试图查看/v 120/时,尽管msmversion被设置为2015年,我还是通过设置VCTargetsPath位置修复了这个错误。

以下是运行npm i -D active-win时的全部错误:

代码语言:javascript
运行
复制
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,其输入的文件夹\V 140实际上是存储配置的地方。丢失的一个文件是Microsoft.Cpp.Default.props。我没能找到有同样问题的人。有很多人都有同样的错误,但是在解决他们的问题时,Microsoft.Cpp.Default.props只是在其他目录中。这是它应该在的目录,它不在那里。

我该怎么解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2019-11-23 06:16:37

首先,我下载了VisualStudio2019,而不是使用node_build_tools。尽管节点构建工具声称已经安装了实际的C:/Program (X86)文件,但/MSBuild并没有其中所需的任何文件。在我完全卸载之前的Visual安装程序之后,2019年的安装程序运行良好。

从那以后就很容易了。下面是你需要做的事情:

  • npm config set msvs_version 2019
  • npm config set msbuild_path "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
  • Then设置VCTargetsPath本地环境变量,不可以简单地在npm或注册表中设置它。我试过了。
    • SET VCTargetsPath=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\
    • (don't忘记了最后一个反斜杠,如果您do)

,它将无法工作

代码语言:javascript
运行
复制
1. GitBash or other bash like shells  
    - `VCTargetsPath="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Microsoft\\VC\\v160\\"`

注意:虽然Visual将允许您选择安装文件夹的位置,这只是IDE将文件保存到计算机上的任何路径或驱动器的默认位置,但上面实际的文件夹总是安装到C:\Program (X86)\\中,所以不要更改该文件夹。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58969271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档