node-gyp构建错误windows x64

问题描述 投票:62回答:10

这是我到目前为止在x64操作系统上所做的事情:

  • 安装Python(v2.7 - 特别是2.7.6)并将其添加到系统路径(C:\ Python27)
  • 已安装的MS VS C ++ 2010 Express版本(我已经安装了VS 2012但没有C ++组件)
  • 安装了Windows SDK 7.1的编译器更新
  • 成功执行了node-gyp configure(来自我在node.spp所在的nodejs \ node_modules下的附加目录)
  • 运行node-gyp build(作为管理员)**这是崩溃的原因,让我:

这个错误:

C:\Program Files\nodejs\node_modules\msnodesql>node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the   "/m" switch.

链接:致命错误LNK1181:无法打开输入文件'kernel32.lib'[C:\ Program Files \ nodejs \ node_modules \ msnodesql \ build \ sqlserver.vcxproj]

gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\RNelson\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\RNelson\\AppData\\Roaming\\npm\\node_modules\\node-      gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\msnodesql
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok

关于发生了什么的任何想法?提前致谢!只是尝试将node-sqlserver MS驱动程序用于Node.js

windows-7-x64 node-gyp node-sqlserver
10个回答
37
投票

当我使用VS节点工具时,npm config set msvs_version 2013 --global为我工作,每次进行npm安装时都不需要指定msvs_version。

我有一个问题,即npm的配置(c:\ Users \ username \ .npmrc)有一个过期的msvs_version = 2012条目。


0
投票

有一个易于使用的windows build tools全局节点包。你可以试试这个。


48
投票

我遇到了类似的问题。我发现这个开关帮助了我

--msvs_version=2012

所以例如

npm install --msvs_version=2012 <package>

18
投票

花了一段时间让这个工作(对我来说,接受的答案没有用,对我来说这只是一半的解决方案)我做了以下:

  1. 可悲的是,你必须有视觉工作室(我为DESKTOP安装了2013年快车版)
  2. 安装了python 2.7.3(你不必设置任何环境变量)
  3. 以管理员身份运行cmd并转到项目根目录(package.json文件在哪里)
  4. 首先:npm config set python C:\Python27\python.exe
  5. 然后:npm install -msvs_version=2013

诀窍在于命令npm config set python ...path_to_python_exe...,它将由npm提供给我需要python的依赖。我不知道为什么将python设置为env变量是不够的。


10
投票

如果以上都不起作用(我的情况 - Windows10 64bit)

删除C:\ Users \ user_name \ .node-gyp

删除%AppData%/ npm

删除%AppData%/ npm-cache

然后再次安装node-gyp

遵循node-gyp page的指示

我选择了选项1 npm install --global --production windows-build-tools


6
投票

用于在Windows或任何其他操作系统中安装node-gyp

首先,您可能需要下载node-gyp

$ npm install -g node-gyp-install

然后安装

$ npm install -g node-gyp

您可能需要以root / administrator身份执行上述过程。


4
投票

我在2015年尝试安装Keystone时遇到了同样的错误,但是我告诉了你所有这些错误,但它本身并没有起作用。最后,我只需要运行命令

"C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\SetEnv.CMD" /Release /x64

在运行命令之前设置环境。 (当它将窗口文本变为绿色时,请不要惊慌失措,它正在工作)。所以是的,我会在互联网上的每个地方以相同的方式进行安装和设置环境变量,但确保在运行任何其他命令之前运行上述命令。它可能对你没用,但希望它对其他人有用。如果仍然无效,MSVS版本2010对我有用,所以安装该版本并在运行npm命令时使用标志-msvs_version = 2010。


1
投票

对我来说,与VS express一起使用的解决方案是简单地安装Visual Studio 2013 Express for desktop(这是唯一一个为您提供2013版本的开发人员命令提示符)。打开开发人员命令提示符(已提升)并运行NPM安装命令。这不需要任何特殊的--msvs_version论点,它只是起作用。


1
投票

我自己遇到了这个问题,这就是我使用Visual Studio 2010解决它的方法:

安装以下包

使用Windows SDK命令提示符中的npm install(您需要这样做,因为它设置了其他环境变量)。

资料来源:node-gyp instructions for VS2010


1
投票

对我来说(Windows 7 64位),

半天一天我在这个问题上挣扎最后它起作用了。

我在途中 :

  1. 在控制面板上,我删除了所有Python,Microsoft Visual Studio,Microsoft Redistributable以及我安装的一些内容来解决这个问题。
  2. 窗口更新并重新启动。
  3. 已安装Python27Visual Studio 2013,没有设置env-val
  4. npm install node-gyp -g
  5. 我得到了一个错误相同的东西,但在npm config set msvs_version 2013 --global后,它的工作原理。
© www.soinside.com 2019 - 2024. All rights reserved.