简体   繁体   English

节点 gyp 构建错误 windows x64

[英]node-gyp build error windows x64

Here's what I've done so far on my x64 OS:到目前为止,这是我在 x64 操作系统上所做的:

  • Installed Python (v2.7 --specifically 2.7.6) and added it to the system path (C:\Python27)安装 Python (v2.7 -- 特别是 2.7.6) 并将其添加到系统路径 (C:\Python27)
  • Installed MS VS C++ 2010 Express Version (I already had VS 2012 but without the C++ component)安装了 MS VS C++ 2010 Express 版本(我已经有 VS 2012 但没有 C++ 组件)
  • Installed the compiler update for Windows SDK 7.1安装了 Windows SDK 7.1 的编译器更新
  • Successfully executed node-gyp configure (from my add-on directory under nodejs\node_modules where binding.gyp is located)成功执行 node-gyp 配置(来自我在 nodejs\node_modules 下的附加目录 binding.gyp 所在的位置)

  • ran node-gyp build (as administrator)** This is what crashed, leaving me with:运行 node-gyp build(以管理员身份)** 这就是崩溃的原因,给我留下了:

this error:这个错误:

C:\Program Files\nodejs\node_modules\msnodesql>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.12.2
gyp info using node@0.10.25 | 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.

LINK: fatal error LNK1181: cannot open input file 'kernel32.lib' [C:\Program Files\nodejs\node_modules\msnodesql\build\sqlserver.vcxproj]链接:致命错误 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

Any ideas as to what is going on?关于发生了什么的任何想法? Thanks in advance!提前致谢! Just trying to use my node-sqlserver MS driver for Node.js只是想将我的 node-sqlserver MS 驱动程序用于 Node.js

I had a similar problem.我有一个类似的问题。 I found that this switch helped me我发现这个开关帮助了我

--msvs_version=2012

so for example所以例如

npm install --msvs_version=2012 <package>

npm config set msvs_version 2013 --global worked for me as I use VS node tools and you dont need to specify msvs_version each time you do an npm install. npm config set msvs_version 2013 --global对我npm config set msvs_version 2013 --global ,因为我使用 VS 节点工具,并且每次执行 npm 安装时都不需要指定 msvs_version。

I had an issue whereby npm's config (c:\\Users\\username\\ .npmrc) has an entry msvs_version=2012 which was out of date.我遇到了一个问题,即 npm 的配置 (c:\\Users\\username\\.npmrc) 有一个条目 msvs_version=2012 已过时。

After spending a while to get this to work (for me accepted answer didn't work, for me it's just half solution) i did following:花了一段时间让它工作(对我来说接受的答案不起作用,对我来说这只是一半的解决方案)我做了以下事情:

  1. Sadly, you must have visual studio (i installed express edition 2013 for DESKTOP)可悲的是,您必须拥有 Visual Studio(我为桌面安装了 express 2013 版)

  2. Installed python 2.7.3 (you don't have to set any environment variables)已安装python 2.7.3(无需设置任何环境变量)

  3. Run cmd as administrator and go to you project root (where is you package.json file)以管理员身份运行 cmd 并转到您的项目根目录(您的 package.json 文件在哪里)

  4. First run: npm config set python C:\\Python27\\python.exe首次运行: npm config set python C:\\Python27\\python.exe

  5. Then: npm install -msvs_version=2013然后: npm install -msvs_version=2013

The trick is in command npm config set python ...path_to_python_exe... which will be provided by npm to dependency which needs python i guess.诀窍在于命令npm config set python ...path_to_python_exe...将由 npm 提供给我猜需要 python 的依赖项。 I don't know why setting python as env variable is not enough.我不知道为什么将 python 设置为 env 变量是不够的。

If all above did not work (my case - Windows10 64bit )如果以上都不起作用(我的情况 - Windows10 64bit

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

Delete %AppData%/npm删除%AppData%/npm

Delete %AppData%/npm-cache删除%AppData%/npm-cache

And install node-gyp again并再次安装node-gyp

Following instruction on node-gyp page按照node-gyp 页面上的说明进行操作

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

For installing node-gyp in windows or any other OS用于在 Windows 或任何其他操作系统中安装 node-gyp

First you may have to download the node-gyp by首先,您可能需要通过以下方式下载 node-gyp

$ npm install -g node-gyp-install

Then install by然后通过安装

$ npm install -g node-gyp

you may need to do the above procedure as root/administrartor.您可能需要以 root/管理员身份执行上述过程。

I had this same error now in 2015 when trying to install Keystone and I ran through all you told me but it didn't work on it's own.我现在在 2015 年尝试安装 Keystone 时遇到了同样的错误,我经历了你告诉我的所有事情,但它本身不起作用。 At the end, I just had to run the command最后,我只需要运行命令

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

to set up the environment before running the command.在运行命令之前设置环境。 (Don't freak out when it turns your window text green, it's working). (当它把你的窗口文本变成绿色时不要惊慌,它正在工作)。 So yeah I'd do the installations and set up environment variables in the same way everywhere on the internet suggests but make sure to run the above command before running any other command.所以是的,我会按照互联网上建议的相同方式进行安装和设置环境变量,但请确保在运行任何其他命令之前运行上述命令。 It probably won't be useful to you, but hopefully it's useful to someone else.它可能对你没有用,但希望它对其他人有用。 If that still doesn't work, MSVS version 2010 worked for me, so install that version and use the flag -msvs_version=2010 when running the npm command.如果这仍然不起作用,MSVS 2010 版对我有用,因此请安装该版本并在运行 npm 命令时使用标志 -msvs_version=2010。

For me the solution that worked with VS express was to simply install Visual Studio 2013 Express for desktop (which is the only one that gives you a developer command prompt as of 2013 version).对我来说,与 VS express 一起使用的解决方案是简单地安装 Visual Studio 2013 Express for desktop(这是唯一一个为 2013 版本提供开发人员命令提示符的)。 Open developer command prompt (elevated) and run NPM install commands.打开开发人员命令提示符(提升)并运行 NPM 安装命令。 This did not require any special --msvs_version arguments, it just worked.这不需要任何特殊的--msvs_version参数,它只是有效。

I came across this problem myself, and this is how I solved it using Visual Studio 2010:我自己遇到了这个问题,这就是我使用 Visual Studio 2010 解决它的方法:

Install following packages安装以下软件包

Use npm install from the Windows SDK command prompt (you need this because it sets additional environment variables).从 Windows SDK 命令提示符使用npm install (您需要它,因为它设置了额外的环境变量)。

Source: node-gyp instructions for VS2010来源: VS2010 的 node-gyp 说明

For me (Windows 7 64bit),对我来说(Windows 7 64位),

I struggled with this issue for half of a day Finally It worked.我在这个问题上挣扎了半天终于成功了。

On my way :在我的路上

  1. At control panel, I deleted all Python, Microsoft Visual Studio, Microsoft Redistributable, and something about I installed to solve this.在控制面板中,我删除了所有 Python、Microsoft Visual Studio、Microsoft Redistributable 以及我安装的一些东西来解决这个问题。

  2. Window Update and restart.窗口更新并重新启动。

  3. Installed Python27 , and Visual Studio 2013 with no setting env-val安装了Python27Visual Studio 2013 ,没有设置 env-val

  4. npm install node-gyp -g

  5. I got an error same thing, but after npm config set msvs_version 2013 --global , It works.我遇到了同样的错误,但是在npm config set msvs_version 2013 --global ,它起作用了。

there is an easy to use windows build tools global node package.有一个易于使用的Windows 构建工具全局节点包。 You could try this.你可以试试这个。

I was also getting similar issues and here is what worked for me.我也遇到了类似的问题,这对我有用。

  • Removed Python and Visual Studio删除了 Python 和 Visual Studio
  • Installed Python 27 and Microsoft Visual Studio with "Desktop development with C++"使用“使用 C++ 进行桌面开发”安装 Python 27 和 Microsoft Visual Studio
  • Setting the python path npm config set python /path/to/executable/python设置python路径npm config set python /path/to/executable/python
  • npm install node-gyp -g
  • node-gyp configure --msvs_version=2013

Just had the same problem.刚遇到同样的问题。 Install NVM (Node version manager) and then open your CMD and use NVM install node@ followed by the version your dependencies need.安装 NVM(节点版本管理器),然后打开 CMD 并使用 NVM install node@ 后跟依赖项所需的版本。 If you don't know what version you might need try playing around with different version I reverted my Node back to version 14.15.0 and then used NPM install and everything ran smoothly!如果您不知道您可能需要什么版本,请尝试使用不同的版本,我将我的 Node 恢复到版本 14.15.0,然后使用 NPM 安装,一切顺利! Hope this helps!希望这可以帮助!

Install chocolatey in PowerShell with administrator permissions:使用管理员权限在chocolatey中安装 Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Install required versions of the Microsoft Build Tools for Visual Studio:https://community.chocolatey.org/packages?q=visual+studio+tools为 Visual Studio 安装所需版本的 Microsoft 构建工具:https://community.chocolatey.org/packages?q=visual+studio+tools

In my case:就我而言:

choco install visualstudio2019buildtools

And install workload:并安装工作量:

cinst visualstudio2017-workload-vctools

Worked with node 16.16.0 If used nvm.使用节点 16.16.0 如果使用 nvm。 Reinstall node version.重新安装节点版本。 And all will work fine.一切都会正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM