Windows node gyp rebuild error

Проблема с node-gyp?

Итак, все началось с того что при установке всех модулей постоянно происходила попытка node-gyp rebuild’а, из за этого некоторые модули не устанавливались, так же выдавало ошибку при node-gyp rebuild, вот логи с установки модуля sleep как пример:

Ниже то как выглядела ошибка в консоли:

Присмотревшись я увидел, что оно требует VS, так же я увидел ссылку на гитхаб, там я увидел нужную мне команду, но при попытке ввода данной команды все зависало на этом моменте.

Я подумал что нужно немного подождать но спустя полчаса ничего не изменилось, я подумал что из за слабого интернета, все таки фулл VS скачивается(вроде много весит), поэтому попробовал с офлайн установщиком, вот что вышло:

Вот логи: https://yadi.sk/d/ljoeVZ8ebEebOg
Я не просто так описал всю проблему с самого начала, так как я не уверен что делаю правильно, помогите решить данную проблему, буду благодарен
Проблема появилась недавно, после чего не помню

  • Вопрос задан 15 авг. 2020
  • 317 просмотров

Поставьте Visual Studio — проблемы как рукой снимет. node-gyp нужен компилятор, чтобы пересобрать себя из исходников.

Он же буржуйским языком говорит ошибку:

Не установлена переменная msvs_version (в которой должна храниться версия Visual Studio).

Тогда пытается прочитать переменную VCINSTALLDIR (в которой должен быть путь к папке установленной Visual Studio) и там неудача.

Говорит, что ни Visual Studio 2017+ ни Visual Studio 2015 не установлено. Более старые — не подойдут.

How to solve ‘node-gyp rebuild’ issue on Windows 10?

As part of trying to use a node NPM dependency in a project, I get a node-gyp rebuild issue, which I have reported.

I am aware of the solution in this SO question, but it does not work for Windows 10 (I am on 32 bits, I don’t know whether this is relevant). Windows SDK 7.1 (and others) won’t install.

Does anyone have an operational solution for Windows 10?

After trying npm install —msvs_version=2013 , I get a new error message:

3 Answers 3

To install node addons, you need to have VC/VCExpress installed and not just the VC runtime/redistributable. Make sure it’s the «Windows Desktop» edition.

After that, you should be able to install addons via npm (you may have to re-open any command prompts you had open before installing VCExpress though).

Читайте также:  Чем измерить быстродействие windows

This worked for me:

I solved this problem on windows 8 and windows 10 pro with this tutorial. I try a lot of times to solve this problem with many different solutions, but only worked for me this
I notice that i didn’t use nodist to control the node version like this tutorial, I use NVM and worked fine, i don’t test this tutorial with nodist. I used node 5.2.0.

Following the suggested by @prasun, the steps in correct order:

  • Download and install Git SCM from HERE
  • Download Visual Studio Community HERE and install a Custom Installation, selecting ONLY the following packages: VISUAL C++, PYTHON TOOLS FOR VISUAL STUDIO and MICROSOFT WEB DEVELOPER TOOLS
  • Download and install Python 2.7.x from HERE
  • Register a Environment Variable with name: GYP_MSVS_VERSION with this value: 2015.

This is the only steps work for me in windows 8.1 and windows 10.

node-gyp build error windows x64

Here’s what I’ve done so far on my x64 OS:

  • Installed Python (v2.7 —specifically 2.7.6) and added it to the system path (C:\Python27)
  • Installed MS VS C++ 2010 Express Version (I already had VS 2012 but without the C++ component)
  • Installed the compiler update for Windows SDK 7.1

Successfully executed node-gyp configure (from my add-on directory under nodejs\node_modules where binding.gyp is located)

ran node-gyp build (as administrator)** This is what crashed, leaving me with:

LINK : fatal error LNK1181: cannot open input file ‘kernel32.lib’ [C:\Program Files\nodejs\node_modules\msnodesql\build\sqlserver.vcxproj]

Any ideas as to what is going on? Thanks in advance! Just trying to use my node-sqlserver MS driver for Node.js

11 Answers 11

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.

I had an issue whereby npm’s config (c:\Users\username\ .npmrc) has an entry msvs_version=2012 which was out of date.

I had a similar problem. I found that this switch helped me

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:

Sadly, you must have visual studio (i installed express edition 2013 for DESKTOP)

Installed python 2.7.3 (you don’t have to set any environment variables)

Run cmd as administrator and go to you project root (where is you package.json file)

First run: npm config set python C:\Python27\python.exe

Then: 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. I don’t know why setting python as env variable is not enough.

If all above did not work (my case — Windows10 64bit)

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

Delete %AppData%/npm

Delete %AppData%/npm-cache

And install node-gyp again

Following instruction on node-gyp page

I chose Option 1 npm install —global —production windows-build-tools

For installing node-gyp in windows or any other OS

First you may have to download the node-gyp by

Then install by

you may need to do the above procedure as root/administrartor.

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. At the end, I just had to run the command

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.

node-gyp rebuild error #94

Comments

ashalaenko commented Jul 5, 2012

The text was updated successfully, but these errors were encountered:

TooTallNate commented Jul 5, 2012

From your prompt it looks like you’re running the command in /usr/local/lib/node_modules . So what module are you trying to build?

TooTallNate commented Jul 5, 2012

ashalaenko commented Jul 5, 2012

So, I tried to use that :
npm install iconv -g

And got this error.

TooTallNate commented Jul 6, 2012

@ashalaenko Can you output the entire log including the command?

jamcoupe commented Jul 14, 2012

I am getting the same issue, is there a solution?

gavinr commented Sep 18, 2012

I’m experiencing this issue too. What was the resolution?

TooTallNate commented Sep 18, 2012

Everyone, node-gyp configure must be run from the root directory of a node module. @jamcoupe Invoking it at / is likely not what you want to do.

gavinr commented Sep 18, 2012

Thanks @TooTallNate. I agree. Just to reiterate, if you are getting this error you need to go to the node module folder (for me this was happening with node-sqlserver, located at USERDIR/node_modules/node-sqlserver ) and run the node-gyp configure command from there. Thanks!

jonbarlo commented Jan 7, 2013

I’m having a problem trying to running node-sqlserver on my windows 7 machine.
Already have installed and working
-node.js
-appFog
-ruby (command prompt)
-python

So what i’ve done so far is to download everything in one «test» folder, when try to execute the node-gyp configure im gettin this:

C:\Users\jonathan.barquero\Documents\node.js source\test>node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.2
gyp info using node@0.8.16 | win32 | x64
gyp info spawn python
gyp info spawn args [ ‘C:\Users\jonathan.barquero\Documents\node.js source
test\node_modules\node-gyp\gyp\gyp’,
gyp info spawn args ‘binding.gyp’,
gyp info spawn args ‘-f’,
gyp info spawn args ‘msvs’,
gyp info spawn args ‘-G’,
gyp info spawn args ‘msvs_version=auto’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘C:\Users\jonathan.barquero\Documents\node.js source
test\build\config.gypi’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘C:\Users\jonathan.barquero\Documents\node.js source
test\node_modules\node-gyp\addon.gypi’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘C:\Users\jonathan.barquero.node-gyp\0.8.16\common.g
ypi’,
gyp info spawn args ‘-Dlibrary=shared_library’,
gyp info spawn args ‘-Dvisibility=default’,
gyp info spawn args ‘-Dnode_root_dir=C:\Users\jonathan.barquero.node-gyp
0.8.16′,
gyp info spawn args ‘-Dmodule_root_dir=C:\Users\jonathan.barquero\Documents
\node.js source\test’,
gyp info spawn args ‘—depth=.’,
gyp info spawn args ‘—generator-output’,
gyp info spawn args ‘C:\Users\jonathan.barquero\Documents\node.js source
test\build’,
gyp info spawn args ‘-Goutput_dir=.’ ]
gyp: binding.gyp not found (cwd: C:\Users\jonathan.barquero\Documents\node.js so
urce\test) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\jonathan.barquero\Document
s\node.js source\test\node_modules\node-gyp\lib\configure.js:420:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command «node» «C:\Users\jonathan.barquero\Documents\node.js source
\test\node_modules\node-gyp\bin\node-gyp.js» «configure»
gyp ERR! cwd C:\Users\jonathan.barquero\Documents\node.js source\test
gyp ERR! node -v v0.8.16
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok

I know im getting the «gyp: binding.gyp not found (cwd: C:\Users\jonathan.barquero\Documents\node.js so
urce\test) while trying to load binding.gyp» but wondering why im getting this error if i do have everything nested in one folder

in within the folder node_modules i have the two github projects (node-gyp & node-sqlserver)

I already tryed to go to the node module folder as @gavreh mentioned but it didnt worked i got the same result, so im afraid im still not getting how to solve this, could any of you guys help me a bit

node-gyp fails to build on Windows 10 #17

Comments

replete commented Oct 10, 2016

I am unable to install this module.

  • Windows 10 Enterprise LTSB latest
  • Windows Build Tools installed via npm
  • Elevated Powershell
  • Latest node-gyp, node, npm

The text was updated successfully, but these errors were encountered:

nstepien commented Oct 10, 2016 •

The Windows SDK version 8.1 was not found.

Please try installing the windows-build-tools again.

replete commented Oct 10, 2016

I have installed windows-build-tools again and rebooted, resulting in the same error.

Perhaps this is an issue of ‘windows-build-tools’? I have no experienced of this package, though I have Visual Studio 2015.3 installed anyway as my IDE.

nstepien commented Oct 10, 2016

Sounds like it.
I’d say open an issue with windows-build-tools, and try to install the «Windows SDK version 8.1» manually.

I could install iltorb just fine on the two windows machines I tried (win 7 and win 10), and they worked just fine with an updated npm and the windows-build-tools installed via elevated PowerShell. I’m not Windows export so that’s as much help as I can give you.

replete commented Oct 10, 2016 •

Thanks for your quick help.
This is the same issue as in #15.

replete commented Oct 10, 2016

I considered installing Windows SDK 8.1 as a workaround, but it appears to be 1.5GB?

Are 1.5GB of libraries really necessary for the compilation of a simple console application?

Given the file size and the quick installation time of ‘windows-build-tools’, it would appear that the SDK is not installed at all by that package.

nstepien commented Oct 10, 2016


I don’t get that 1.5GB figure from that installer.

I can’t find a reference to the SDK itself in the windows-build-tools repo, maybe this is enough?

Читайте также:  Правильная оптимизация windows 10
Оцените статью