Node gyp configure error

λ npm install node-sass@4.9.3 install C:varwwwproject-dirnode_modulesnode-sass node scripts/install.js Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.3/win32-...

λ npm install

node-sass@4.9.3 install C:varwwwproject-dirnode_modulesnode-sass
node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.3/win32-x64-72_binding.node
Cannot download «https://github.com/sass/node-sass/releases/download/v4.9.3/win32-x64-72_binding.node»:

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.

  export HTTP_PROXY=http://example.com:1234                                                                                                                                                                                                          

or configure npm proxy via

  npm config set proxy http://example.com:8080                                                                                                                                                                                                       

node-sass@4.9.3 postinstall C:varwwwproject-dirnode_modulesnode-sass
node scripts/build.js

Building: C:Program Filesnodejsnode.exe C:varwwwproject-dirnode_modulesnode-gypbinnode-gyp.js rebuild —verbose —libsass_ext= —libsass_cflags= —libsass_ldflags= —libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli ‘C:Program Filesnodejsnode.exe’,
gyp verb cli ‘C:varwwwproject-dirnode_modulesnode-gypbinnode-gyp.js’,
gyp verb cli ‘rebuild’,
gyp verb cli ‘—verbose’,
gyp verb cli ‘—libsass_ext=’,
gyp verb cli ‘—libsass_cflags=’,
gyp verb cli ‘—libsass_ldflags=’,
gyp verb cli ‘—libsass_library=’
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@12.6.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing «build» directory
gyp verb command configure []
gyp verb check python checking for Python executable «C:Python37python.exe» in the PATH
gyp verb which succeeded C:Python37python.exe C:Python37python.exe
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:Python37python.exe -c import sys; print «%s.%s.%s» % sys.version_info[:3];
gyp ERR! stack File «», line 1
gyp ERR! stack import sys; print «%s.%s.%s» % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:297:12)
gyp ERR! stack at ChildProcess.emit (events.js:203:13)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command «C:Program Filesnodejsnode.exe» «C:varwwwproject-dirnode_modulesnode-gypbinnode-gyp.js» «rebuild» «—verbose» «—libsass_ext=» «—libsass_cflags=» «—libsass_ldflags=» «—libsass_library=»
gyp ERR! cwd C:varwwwproject-dirnode_modulesnode-sass
gyp ERR! node -v v12.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {«os»:»darwin»,»arch»:»any»} (current: {«os»:»win32″,»arch»:»x64″})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.3 postinstall: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersUserNameAppDataRoamingnpm-cache_logs2020-03-12T13_15_02_615Z-debug.log

λ npm -v
6.14.2

λ node -v
v12.6.0

Содержание

  1. gyp ERR! configure error #2069
  2. Comments
  3. npm install fails due to node-gyp errors #2113
  4. Comments
  5. Hackers and Slackers
  6. Fixing your NPM Installation
  7. Reinstalling Node
  8. Create a New Global NPM Directory
  9. You Did Good
  10. gyp ERR! build error #983
  11. Comments

gyp ERR! configure error #2069

node-sass@4.9.3 install C:varwwwproject-dirnode_modulesnode-sass
node scripts/install.js

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.

or configure npm proxy via

node-sass@4.9.3 postinstall C:varwwwproject-dirnode_modulesnode-sass
node scripts/build.js

Building: C:Program Filesnodejsnode.exe C:varwwwproject-dirnode_modulesnode-gypbinnode-gyp.js rebuild —verbose —libsass_ext= —libsass_cflags= —libsass_ldflags= —libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli ‘C:Program Filesnodejsnode.exe’,
gyp verb cli ‘C:varwwwproject-dirnode_modulesnode-gypbinnode-gyp.js’,
gyp verb cli ‘rebuild’,
gyp verb cli ‘—verbose’,
gyp verb cli ‘—libsass_ext=’,
gyp verb cli ‘—libsass_cflags=’,
gyp verb cli ‘—libsass_ldflags=’,
gyp verb cli ‘—libsass_library=’
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@12.6.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing «build» directory
gyp verb command configure []
gyp verb check python checking for Python executable «C:Python37python.exe» in the PATH
gyp verb which succeeded C:Python37python.exe C:Python37python.exe
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:Python37python.exe -c import sys; print «%s.%s.%s» % sys.version_info[:3];
gyp ERR! stack File «», line 1
gyp ERR! stack import sys; print «%s.%s.%s» % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:297:12)
gyp ERR! stack at ChildProcess.emit (events.js:203:13)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command «C:Program Filesnodejsnode.exe» «C:varwwwproject-dirnode_modulesnode-gypbinnode-gyp.js» «rebuild» «—verbose» «—libsass_ext=» «—libsass_cflags=» «—libsass_ldflags=» «—libsass_library=»
gyp ERR! cwd C:varwwwproject-dirnode_modulesnode-sass
gyp ERR! node -v v12.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted <«os»:»darwin»,»arch»:»any»>(current: <«os»:»win32″,»arch»:»x64″>)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.3 postinstall: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersUserNameAppDataRoamingnpm-cache_logs2020-03-12T13_15_02_615Z-debug.log

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

Источник

npm install fails due to node-gyp errors #2113

  • Node Version: v14.1.0
  • Platform: Microsoft Windows 10 Home, 10.0.18363 Build 10.0.18363
  • Compiler: MSBuild 15.0, using VS 2019 and Python 3
  • Module: Any module, in this case robotjs

Verbose output (from npm or node-gyp):

npm —verbose
npm info it worked if it ends with ok
npm verb cli [
npm verb cli ‘C:nodejsnode.exe’,
npm verb cli ‘C:nodejsnode_modulesnpmbinnpm-cli.js’,
npm verb cli ‘—verbose’
npm verb cli ]
npm info using npm@6.14.4
npm info using node@v14.1.0

where is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami

npm -h quick help on
npm -l display full usage info
npm help search for help on
npm help npm involved overview

Specify configs in the ini-formatted file:
C:UsersShubham Bhardwaj.npmrc
or on the command line via: npm —key value
Config info can be viewed via: npm help config

Error Description > robotjs@0.6.0 install C:nodejsnode_modulesrobotjs > prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=14.1.0 runtime=node arch=x64 libc= platform=win32)
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildCurrentBinMSBuild.exe ENOENT
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
gyp ERR! stack at onErrorNT (internal/child_process.js:468:16)
gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:84:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command «C:nodejsnode.exe» «C:nodejsnode_modulesnode-gypbinnode-gyp.js» «rebuild»
gyp ERR! cwd C:nodejsnode_modulesrobotjs
gyp ERR! node -v v14.1.0
gyp ERR! node-gyp -v v6.1.0
gyp ERR! This is a bug in node-gyp .
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR! https://github.com/nodejs/node-gyp/issues
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! robotjs@0.6.0 install: prebuild-install || node-gyp rebuild
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the robotjs@0.6.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersShubham BhardwajAppDataRoamingnpm-cache_logs2020-05-03T09_31_41_003Z-debug.log

I tried a lot of solutions, but of no use.
Please guide the way forward. I’ve been stuck on this for 2-3 days now.

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

@cclauss @vadimpopa Can you suggest some way out please?

What do you get when you run

(include the quotes) in the console?

What do you get when you run

(include the quotes) in the console?

Same problem here.
I’ve run MSBuild.exe.

Here’s the output:

C:WorkIonic>»c:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrentBinMSBuild.exe»
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.

@bzoz I get the same output on the console as @Youkko ! Any insight on what’s causing this?

I am also getting same issue. anyone tried a lower version than 2019 MsVS?

I dont know if I am going in the correct direction. But I installed MSVS 20115 yesterday and retried

I am getting a different error now because of node-pty

MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
ion in the project property pages or by right-clicking the solution and selecting «Retarget solution».

Got rid of this error by changing Node.JS version (from 8.x to 10.x).

What do you get when you run

(include the quotes) in the console?

I’m getting this: «The system cannot find the path specified.»

What do you get when you run

(include the quotes) in the console?

I’m getting this: «The system cannot find the path specified.»

Make sure you have that Visual Studio version. You’re trying to execute MSBuild.exe from Visual Studio Community edition’s folder. Do you have it installed in this folder?
I use Visual Studio Professional, so mine is in a different folder
(c:Program Files (x86)Microsoft Visual Studio2019 Professional MSBuildCurrentBinMSBuild.exe)
Change this file location to your visual studio folder and you should get it.

@ShubhamB99 could you provide the entire verbose log including the command you are using? Add —verbose to whatever npm command you are using that causes this issue.

@Youkko @TulasiJagan49, @nandas your issues could be completely unrelated. Please provide the entire verbose log and your system configuration — basically fill out the issue template. Fell free to open separate issues.

@nandas VS2019 works just fine with node-gyp, no need to downgrade.

This works for me 🙂

Is this issue is solved?

@ShubhamB99 did you ever solve this issue? I know it was a while ago but I am running into a very similar problem now.

@gideonm-pangea what are you trying to do (provide a command you are trying to run, but with —verbose flag). And then provide the output of command. Please, formate output as code snippet (put it into «` (triple backquote on an otherwise blank line before and after command output))

@owl-from-hogvarts I myself am not currently having this issue but I do remember that I fixed it, don’t remember how. it seems like these errors aren’t caused by a bug but by node-gyp being improperly set up by the user, but I do think that maybe the error messages should be a bit more descriptive as to the error and the solution.

How I can make it work?

@reduardo7 what npm version do you use? and what output did you get?

@owl-from-hogvarts Thank you for your help!

Here more details:

Not working, help me please. Im installing tars-cli and get errors. (python — inst, Visual studio installer and C++ — inst )

Источник

Hackers and Slackers

Fixing your NPM Installation

Resolve a common NPM issue where users receive EACCES error messages upon NPM library installation.

There’s a bit of a headache going around with respect to global npm permissions. For those of us working on Unix-based systems, it’s not uncommon to come across error messages complaining about your user permissions whenever installing new npm packages, especially when installing them globally.

If errors like the one below look familiar, you’re not alone:

NPM permission errors

This is a textbook case of being trigger-happy with the sudo command. If you’re installing npm as a user other than root, it’s a bad idea to install Node + npm with the sudo command. If a non-root user installs dependencies by escalating privileges via sudo , the installation will appear to succeed. However, we’ve just created a scenario where the user in question does not have permission to modify global npm the user just installed (nor modify/install packages). When we installed Node/NPM with sudo , we handed exclusive ownership to the root user. That would mean we’d have to specify sudo before every global package install, which is annoying but more importantly unrealistic.

It gets worse. Npm packages that require post-install scripts to be run simply become impossible to install. Sometimes you might be able to get away with the following, but only if the scripts aren’t necessary:

Install NPM package without running scripts post-execution

When the scripts are necessary, like in the case of node-sass , we’re shit outta luck. Using the —ignore-scripts flag just results in a broken install. Attempting to install using sudo looks like this:

Install node-sass globally

NPM package installation error

Why does this happen? Because by default, the post-install scripts attempt to run as the current user. Since the current user doesn’t have permissions to mess with packages installed globally, the installation ultimately fails. To fix this, we need to reinstall Node the correct way.

Reinstalling Node

I’m working under the assumption that we’re using Ubuntu or a Debian-based Linux distro. The first thing we need to do is remove Node:

Verify that Node is gone:

Check Node version

If a folder path is returned by the above, nuke it. That should leave us ready for a fresh install.

Since we’re on a Debian system, we need to install Node via Nodesource. I’d recommend running this in the /tmp folder, or wherever you like to dump things saved from the internet:

Install Node from source

Now would be a good time to get the latest npm as well:

When the installation is complete, check to see if everything worked:

Check Node version Check NPM version

Create a New Global NPM Directory

With Node reinstalled, we can move on to creating and configuring a new directory to hold our global npm modules. You can name this what you want, but it’s generally recommended to name this npm-global or something of the sort. Don’t use sudo !

Create a new home for global NPM modules

Now we can configure npm to recognize this folder:

Next, we need to add this to our PATH. This should go in

/.bash_profile , depending on which you use):

Recognize new NPM path on startup

You Did Good

That should do it! From now on, remember to stray away from using sudo when installing Node, npm, or even modifying npm packages. The npm documentation explicitly recommends against this, but it’s all good. We all make mistakes.

Источник

gyp ERR! build error #983

Are two days that I try to install the canvas to use with gitbook, I tried in every way, I’ve read many tutorials on the web, already removed and reinstalled node.js, python 2.7, GTK2 Microsoft Visual Studio Community.

But solves nothing and still keep getting the following message when trying to install the canvas, I tried to install node-gyp alone and has followed several tutorials, but solves nothing.

Here is what I get from the canvas when trying to install it if you can guide me step by step, I will be happy to follow, and I think it can be useful for many, as I see it is a very common problem.

Thank you so much.

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

and it did not work, nothing changes.

I tried this option as well, using Visual Studio 2015: https://github.com/nodejs/node-gyp#installation

All my software is licensed with academic versions of my name through the Spark Dreams.

To get around the __pfnDliNotifyHook2 error you need to build with node-gyp@3.4.0 . This error:

gyp: binding.gyp not found (cwd: c:Usersconsu_000GitBookLibrarycursoarduinointroducao-a-linguagem-de-programacao) while trying to load binding.gyp

Means you’re running node-gyp build or node-gyp rebuild in the wrong directory. binding.gyp is provided by the add-on and is normally in its top-level directory. Good luck!

Hello @bnoordhuis, what would be the correct directory to be executed in this case?

I’ve tried as said following several tutorials, and have tried to create the binding.gyp, the problem occurs when trying to install plugins for gitbook, and when trying to install node-gyp alone or when you install the canvas.

I’m not a connoisseur of Node-JS, can even turn out to be, but my goal is to just use the gitbook per hour, please give me a more precise guidance on how to solve the problem?

If you have the source of the add-on checked out, it’s usually the top-level directory. If you’re trying to install an add-on through npm, you need to ensure that npm uses the right node-gyp version.

I believe npm v2.15.9 comes with node-gyp v3.4.0. It looks like you’re using v2.15.8.

Thanks for the answer.

I am new to node.js and tools, right now I’m just using to install gitbook, I intend to in the future estua it better, even to be able to contribute much to the gitbook as the Jekyll.

I tried to install another version cited, but it did not work, what to do step by step to correct this problem?

npm install -g node-gyp@2.15.8 should read npm install -g npm@2.15.9 — you want to update all of npm, not just node-gyp.

Well, I could not install the 2.15.8 version because it does not exist, but had success with 2.0.0 and so I was trying the version according to the list below and succeeded to the current version.

I did the process:

and finally it worked.

Thanks for the help, so decide what must remove it and test in a virtual machine and document in my language, post a tutorial on my public site.

On Ubuntu 14.04 I tried successfully:

i’m getting the same type cast error on windows 10 with npm@3.7.5 and node-gyp@3.5.0.:

updating npm to 4.1.1 seems to have fixed the issue.

gyp ERR! build error
gyp ERR! stack Error: C:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0BinMSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (E:Devnodejsinstallationdirnode_modulesnpmnode_modulesnode-gyplibbuild.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.18363
gyp ERR! command «E:Devnodejsinstallationdirnode.exe» «E:Devnodejsinstallationdirnode_modulesnpmnode_modulesnode-gypbinnode-gyp.js» «rebuild»
gyp ERR! cwd E:DevOpenSourceGssoc2020BlogManback-endnode_modulesrecommender
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN back-end@1.0.0 No description
npm WARN back-end@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted <«os»:»darwin»,»arch»:»any»>(current: <«os»:»win32″,»arch»:»x64″>)

npm ERR! code ELIFECYCLE
npm ERR! recommender@3.0.0 install: node-gyp rebuild
npm ERR!
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAbirAppDataRoamingnpm-cache_logs2020-03-28T15_34_07_302Z-debug.log
PS E:DevOpenSourceGssoc2020BlogManback-end> node-gyp -v
node-gyp : The term ‘node-gyp’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try again.

6.13.4
PS E:DevOpenSourceGssoc2020BlogManback-end> npm uninstall -g node-gyp
up to date in 0.036s
PS E:DevOpenSourceGssoc2020BlogManback-end> npm install -g node-gyp@versaolista
npm ERR! code ETARGET
npm ERR! notarget No matching version found for node-gyp@versaolista.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn’t exist.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAbirAppDataRoamingnpm-cache_logs2020-03-28T15_37_23_234Z-debug.log
PS E:DevOpenSourceGssoc2020BlogManback-end> npm install -g node-gyp@3.4.0 —save
npm WARN deprecated mkdirp@0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated request@2.88.2: request has been deprecated, see request/request#3142
C:UsersAbirAppDataRoamingnpmnode-gyp -> C:UsersAbirAppDataRoamingnpmnode_modulesnode-gypbinnode-gyp.js

  • node-gyp@3.4.0
    added 109 packages from 69 contributors in 12.544s
    PS E:DevOpenSourceGssoc2020BlogManback-end> npm install -g recommender

recommender@3.0.0 install C:UsersAbirAppDataRoamingnpmnode_modulesrecommender
node-gyp rebuild

Источник

  1. Главная
  2. Front-end
  3. Установка node-gyp на Windows 8

Для работы некоторых модулей Node.js (например, MongoDB, Sails.js, Deployd) нужна компиляция нативного кода, написанного на C++. Это возможно с помощью модуля node-gyp, который, в свою очередь, собирает V8 используя питоновский gyp. Поэтому настроить node-gyp на Windows не просто, хотя на Ubuntu Linux у меня проблем с этим не возникало. В этом посте я поделюсь своим опытом исправления ошибок, которые возникали у меня при установке node-gyp на Windows, и опишу последовательность действий, которая позволила мне заставить сборку работать.

Для установки node-gyp необходимы Python и C++. Поэтому сначала ставим:

  • Python 2.7
  • Microsoft Visual Studio C++ 2013 for Windows Desktop Express
  • и Windows 7 64-bit SDK, если у вас 64-битная система.

После этого надо запустить установку node-gyp глобально:

Если node-gyp установлен локально для проекта, то в некоторых случаях возможна ошибка Failed at install script ‘node-gyp rebuild’, например:

npm ERR! bufferutil@1.2.1 install: `nodegyp rebuild`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the bufferutil@1.2.1 install script ‘node-gyp rebuild’.

npm ERR! Make sure you have the latest version of node.js and npm installed.

npm ERR! If you do, this is most likely a problem with the bufferutil package,

npm ERR! not with npm itself.

Если у вас не установлен Python, или Node.js не может его найти, возникает ошибка Can’t find Python executable “python”, you can set the PYTHON env variable:

> node-gyp rebuild

gyp info it worked if it ends with ok

gyp info using node-gyp@3.3.0

gyp info using node@5.5.0 | win32 | x64

gyp ERR! configure error

gyp ERR! stack Error: Cant find Python executable «python», you can set the PYTHON env variable.

...

gyp ERR! node -v v5.5.0

gyp ERR! node-gyp -v v3.3.0

gyp ERR! not ok

Это лечится установкой Python 2.7 (важно ставить именно эту версию, не знаю почему, но версия 3 не поддерживается!), и указанием в терминале пути к исполняемому файлу питона:

set PYTHON=C:UsersIrinaAppDataLocalProgramsPythonPython27python.exe

Но указывать путь нужно будет каждый раз, когда вы запускаете node-gyp. Поэтому, если вы используете кастомный терминал (а я надеюсь, что вы это делаете), то лучше добавить эту команду в список команд, которые выполняются при запуске терминала.

Если не найден компилятор С++, то вы увидите ошибку `gyp` failed with exit code: 1:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

> node-gyp rebuild

gyp info it worked if it ends with ok

gyp info using node-gyp@3.3.0

gyp info using node@5.5.0 | win32 | x64

gyp http GET https://nodejs.org/download/release/v5.5.0/node-v5.5.0-headers.tar.gz

gyp http 200 https://nodejs.org/download/release/v5.5.0/node-v5.5.0-headers.tar.gz

gyp http GET https://nodejs.org/download/release/v5.5.0/SHASUMS256.txt

gyp http GET https://nodejs.org/download/release/v5.5.0/win-x64/node.lib

gyp http GET https://nodejs.org/download/release/v5.5.0/win-x86/node.lib

gyp http 200 https://nodejs.org/download/release/v5.5.0/SHASUMS256.txt

gyp http 200 https://nodejs.org/download/release/v5.5.0/win-x86/node.lib

gyp http 200 https://nodejs.org/download/release/v5.5.0/win-x64/node.lib

gyp info spawn C:UsersIrinaAppDataLocalProgramsPythonPython27python.exe

gyp info spawn args [ ‘C:\Users\Irina\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py’,

...

gyp info spawn args   ‘-Goutput_dir=.’ ]

gyp: binding.gyp not found (cwd: C:UsersIrinaDocumentsproject) 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:UsersIrinaAppDataRoamingnpmnode_modulesnode-gyplibconfigure.js:305:16)

gyp ERR! stack     at emitTwo (events.js:100:13)

gyp ERR! stack     at ChildProcess.emit (events.js:185:7)

gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

gyp ERR! System Windows_NT 6.3.9600

gyp ERR! command «C:\Program Files\nodejs\node.exe» «C:\Users\Irina\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js» «rebuild»

gyp ERR! cwd C:UsersIrinaDocumentsproject

gyp ERR! node -v v5.5.0

gyp ERR! node-gyp -v v3.3.0

gyp ERR! not ok

Чтобы ее исправить, надо поставить Visual Studio C++ 2013 Express, ссылка на нее есть в начале поста. Имейте в виду, что это огромная среда, которая займет 6,5 гигабайт (!) места на диске (в такие моменты я особенно сильно ненавижу винду – компилятор gpp на Ubuntu в установленном виде занимает всего 17Мб). После этого надо перезагрузить компьютер, и запустить node-gyp rebuild.


© 2012-2023 Блог Ирины Соколовской


Update: After updating to Big Sur getting the following :

xcode-select: error: invalid developer directory

This will also be solved by the following post recommendation.

So you are running npm install but keep failing?

npm install // 

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1

Welcome to the club! This basically happens once after an OS update ( in my case Catalina 10.15.+). All of a sudden npm cant install some packages that need the gyp.

What is the gyp?

Another great question – I am just a javascript developer whats all of this? a gyp is a tool that compiles Node.js Addons. Node.js Addons are native Node.js Modules, written in C or C++, which therefore need to be compiled locally. After they are compiled with tools like node-gyp, their functionality can be accessed via require(), just as any other Node.js Module.

In Summary, not all the libraries we import to our project are written in JavaScript, some of them are written in compiled languages such as c,c++ as Addon – these languages need to be compiled on your local machine since whoever wrote them did not create a compiled version for each OS out-there. The correct way is simply just to download the code before compilation and compile it locally using your local c or c++ compiler hence the gyp which on mac comes in the developer tools/code. Now the creator of the add-on can address every OS easily.

Fixing the issue – gyp ERR! configure error

The easy way out is just to try and reset the xcode using the command:

sudo xcode-select --reset

For me this didnt help so I needed to reinstall my xcode using the following:

sudo rm -rf $(xcode-select --print-path)

xcode-select --install

We basically delete the current version we have which sits in the path : xcode-select –print-path and install it again. Now I can re run npm install and everything is back to normal.

via GIPHY

Hope this was helpful! On the way, you have learned that not all Javascript models are equal and some are not written in Javascript at all. They are what’s called Addons that are written in c++ and are compiled only after you download them into your machine!

Check out the rest of the posts on web development in Javascript.

References:

  • https://stackoverflow.com/questions/39739626/what-is-node-gyp
  • https://nodejs.org/api/addons.html


Also published on Medium.

node-gyp, short for generate your projects, is a tool that lets us build native add-ons for Node.js. Due to historical reasons, which we’ll outline in this article, using node-gyp can easily result in problems that are hard to resolve.

In this article, we’ve grouped all the major issues with node-gyp into three categories, including dependencies of node-gyp, add-on compilation errors, and binding contract violation. We’ll review each category one-by-one, offering solutions along the way.

If you aren’t already familiar with node-gyp or haven’t run into these issues yourself, I recommend reviewing the project’s README file first. Let’s get started!

node-gyp dependencies

Before we start, it’s important to note that if you have Node.js installed, you probably already have node-gyp installed but not exposed globally. If you only need to compile add-ons during the project setup, Node.js should cover it for you. However, if you are an add-on developer, you probably need to install node-gyp globally.

To use node-gyp, first, we’ll need to install a Python runtime, the make utility, and a C or C++ compiler. Already, we run into an issue with the first requirement. node-gyp expects Python ≥v3.6, not Python v2.x. If you’re not a Python developer, you might not realize that Python v.3 isn’t backward-compatible with its previous major version.

Additionally, many modern operating systems provide default runtimes from the first boot-up, however, these runtimes may not comply with node-gyp’s requirements. Be sure to properly install the correct dependencies for your system before starting with node-gyp.

Lastly, many software developers tend to miss the CPU architecture, frequently assuming that the 64-bit version of the x86 instruction set will work. But as new CPUs constantly appear on the market, this could not be further from the truth.

Add-on compilation errors

Usually, developers write add-ons for Node.js in C with N-API bindings or C++ with NAN bindings. We’ll cover bindings in depth later on, but for now, keep in mind that there are at least two ways to bridge the add-on code to the Node.js runtime.

Usually, when you install an external dependency that uses node-gyp, node-gyp will download pre-built binaries that match your architecture and the Node.js version on your system. node-gyp will compile the add-on code only when it doesn’t find a match, which can cause problems.

Most programming languages are backward-compatible, or at least have a minor release version that is. Imagine that the author of an add-on wrote the code but used a higher version of a language than the one supported on your system. You simply would not be able to compile the add-on.

To solve compilation errors, you can either fork its codebase or upgrade or downgrade your compiler toolchain.

Binding contract violation

Previously, we mentioned two types of bindings, NAN, Native Abstraction for Node.js, and Node-API, formerly known as N-API. The third type of bindings include V8, libuv, and Node.js header files.

V8 is a JavaScript and WebAssembly engine used by Node.js. Libuv is a C library used by Node.js to get support for asynchronous I/O.

The first binding method, NAN, provides header files that enable add-ons to interact directly with the V8 runtime. It is similar to using plain V8 header files, just with extra precaution. Since every Node.js release might use a different V8 version, add-ons that use NAN indirectly depend on the V8 version utilized by their users.

If an add-on code expects more or different functionality from V8 than what it provides, the add-on can fail during the linking phase. Or worse, linking may succeed, only for the add-on to crash during runtime due to the presence of incorrect header files.

To remedy these pitfalls, Node.js now exposes Node-API, a stable API independent from the JavaScript runtime. However, this method is not perfect either. The target Node version needs to implement Node-API in the version used by the add-on. To know which version of Node-API you can use against a particular Node.js installation, you should check the version matrix.

Sadly, there is no simple solution for binding contract violations. If you’re the code’s author, you could adjust it, otherwise, you may need to upgrade or downgrade your Node.js version. Later in the article, we’ll cover a few more generic ways to deal with similar issues.

Issue categorization

You may have already realized that the problems reported as node-gyp issues are, in fact, issues with the toolchain used for building add-on code. Now, let’s cover how to categorize the issue to apply the correct solution. When you run into a problem, you can ask yourself the following question:

  • Who is the issue reporter? Is it an add-on publisher or an add-on consumer?
  • What is the architecture and the toolchain of your machine?
  • What are the target Node.js versions?
  • Does the add-on use NAN or Node-API?
  • Which programming language does the add-on use?

Simply put, the add-on publisher has more tools at their disposal when fixing potential problems than a consumer. The architecture and the toolchain influence the whole build process. The target Node.js versions might impair the way NAN cooperates, and some low versions do not support Node-API. The programming language of the add-on influences the contact point between Node and the NAN/Node-API bindings.

It’s worth noting that one installation of an add-on that uses node-gyp for building could trigger many issues, each in different categories.

Checking the architecture and toolchain requires knowledge about the software and hardware of your machine. You should acquire information about your operating system and the CPU/GPU. You likely work on an x86-64-compatible instruction set, but it’s better to verify this information.

To check the version of Python 3 currently used on your terminal, run the following command:

python3 --version

In your terminal, run the command below to check what version of the C/C++ compiler toolchain you’re using:

gcc --version

To check the Node.js version on your machine, use the following code:

node --version

You can dynamically change the executed Node.js version with a Node.js version manager, like either n, available on Linux and macOS, or nvm. However, to avoid using each tool in an automated way, which could cause some of the issues we’ve previously listed, we’ll check the add-on bindings.

Checking the add-on bindings

We need to have access to the codebase of the said add-on. The most important file we need to look into is the binding.gyp file, usually located in the root directory of the add-on. We should search for all require statements in it; require("nan") indicates that the add-on uses NAN, and require("node-addon-api") indicates that the add-on uses Node-API.

For further clarification, you can see examples on GitHub of binding.gyp files in NAN and Node-API.

We can also search the entire project for either NAN or Node-API macros, #include <nan.h> and #include <node_api.h>. Some projects may also use V8 header files, which use #include <v8.h> macros.


More great articles from LogRocket:

  • Don’t miss a moment with The Replay, a curated newsletter from LogRocket
  • Learn how LogRocket’s Galileo cuts through the noise to proactively resolve issues in your app
  • Use React’s useEffect to optimize your application’s performance
  • Switch between multiple versions of Node
  • Discover how to animate your React app with AnimXYZ
  • Explore Tauri, a new framework for building binaries
  • Compare NestJS vs. Express.js

Checking the programming language

You should see the programming language by the filename extensions. C uses .h for header files and .c for source files. On the other hand, C++ uses .h, .hpp, and .hxx for header files and .cpp and .cxx for source files.

Add-ons that use the node-addon-api module are C++ projects. Otherwise, it would be pointless to get declarations of C++ wrapper classes with no intention of using them.

Generic troubleshooting strategies

At this point, if you’ve implemented the above solutions and still haven’t solved the problem you’re facing, we’ve prepared a few generic ideas to try out.

Setting up the Node.js environment and node-gyp dependencies might not be straightforward on your operating system. As an alternative, let’s try building the add-on in a Docker image instead of your local machine, allowing you to control all the dependencies, including the operating system. If you can build the Docker image but still have trouble with your local setup, you’ll know where the problem lies.

As an example, we’ve prepared the following Dockerfile snippet, which builds the SQLite3 add-on on an Alpine Linux instance:

FROM alpine:3.14.2
RUN apk update
RUN apk add --no-cache 
   build-base 
   curl 
   git 
   linux-headers 
   nodejs 
   npm 
   py3-pip 
   python3 
   python3-dev 
   sqlite
RUN pip3 install --upgrade pip

WORKDIR /opt/showcase

RUN npm init -y
RUN apk add sqlite
RUN npm install sqlite3 --verbose --build-from-source

You can save it as Dockerfile in the directory of your choice and run with docker build .

We used Alpine Linux because of its lightweight nature. You may have noticed that we had to add our dependencies by hand. As an exercise, you can remove some dependencies and see how each influences the installation of SQLite3. Additionally, you might check the proposed Dockerfile for node-rdkafka, although it is somewhat dated.

You might also try changing the architecture within the Docker image, for instance, you can choose a 32-bit version of Ubuntu. We trust you can use this hint for old projects, but please note that it is rather unlikely for you to run a 64-bit virtualized operating system on a 32-bit host.

Upgrading or downgrading a Node.js version is trivial with Docker. To speed up the process, the Node.js Docker Team provides Docker images for different versions.

If you have access to the codebase of a NAN-based add-on, you might try to switch to Node-API. It requires you to have prior experience with writing add-ons. You should as well have enough resources to undertake such a task.

Conclusion and resources

Hopefully, by the end of this tutorial, you’ve been able to resolve your issue with node-gyp. We learned how to categorize issues into three common categories by asking a series of questions, then offered unique solutions tailored to each category. We then provided a more generic, universal solution to node-gyp issues that uses a Dockerfile.

In rare instances where the steps proposed above don’t work for you, you can browse the following resources and support channels. I hope you enjoyed this tutorial and have a stronger understanding of node-gyp.

Resources:

  • https://nodejs.org/api/addons.html
  • https://nodejs.org/api/n-api.html
  • https://github.com/nodejs/node-addon-api
  • https://github.com/mapbox/node-pre-gyp

Support:

  • StackOverflow
  • GitHub Issues of NAN
  • GitHub Issues of Node-API
  • Node.js Add–on API Working Group

200’s only Monitor failed and slow network requests in production

Deploying a Node-based web app or website is the easy part. Making sure your Node instance continues to serve resources to your app is where things get tougher. If you’re interested in ensuring requests to the backend or third party services are successful, try LogRocket. LogRocket Network Request Monitoringhttps://logrocket.com/signup/

LogRocket is like a DVR for web and mobile apps, recording literally everything that happens while a user interacts with your app. Instead of guessing why problems happen, you can aggregate and report on problematic network requests to quickly understand the root cause.

LogRocket instruments your app to record baseline performance timings such as page load time, time to first byte, slow network requests, and also logs Redux, NgRx, and Vuex actions/state. Start monitoring for free.

Понравилась статья? Поделить с друзьями:
  • Node express 500 error
  • Node exit process with error
  • Node error spawn unknown
  • No space left on device как исправить
  • No space between attributes как исправить