Содержание
- gyp ERR! configure error #2069
- Comments
- npm install fails due to node-gyp errors #2113
- Comments
- Hackers and Slackers
- Fixing your NPM Installation
- Reinstalling Node
- Create a New Global NPM Directory
- You Did Good
- gyp ERR! build error #983
- 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
Источник
Необходимо определиться с версией, которая вам нужна. Я предпочитаю ставить не новейшую версию Node.js, а последнюю LTS.
Установка в Elementary OS, Ubuntu:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Установка в Debian:
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs
Инструкции под разные системы и для разных версий от разработчиков.
Проверка версий:
nodejs -v
npm -v
Если для проекта вы делаете:
npm install
И вылезает ошибка, вроде:
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/.../node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.3.0-42-generic
gyp ERR! command "/usr/bin/node" "/home/.../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/.../node_modules/node-sass
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.10.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.10.0 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! /home/d1mon/.npm/_logs/2020-03-31T05_52_52_174Z-debug.log
Необходимо удалить каталог node_modules
и файл блокировки package-lock.json
, очистить кэш и пробовать заново:
rm -rf node_modules package-lock.json
npm cache clean --force
npm install
Глобальная установка пакетов
Для глобальной установки пакетов в команду добавляется параметр -g
. Но это не будет работать по умолчанию из-за проблем с правами доступа, поэтому предварительно требуется сделать следующее.
Создадим каталог для глобальных установок:
mkdir ~/.npm-global
Настройка npm на использование нового каталога:
npm config set prefix '~/.npm-global'
В файл ~/.profile
необходимо добавить строку:
export PATH=~/.npm-global/bin:$PATH
В командной строке снова, для применения изменений:
source ~/.profile
На этом все, теперь можно устанавливать пакеты глобально.
It’s a common practice using node.js for front-end app development. In the Windows dev environment, the same exercise applies. If you use Windows Subsystem for Linux (WSL), you can make use of the Linux environment for it. But what if you want to keep your dev environment on Windows 11? One of the most infamous errors you might be able to see is related to the node-gyp
package. Throughout this post, I’m going to discuss how to fix the node-gyp
error on Windows 11.
node-gyp
Package Dependencies
The node-gyp
package is a part of npm, which is automatically installed while installing node.js. Therefore, you should be aware of your node.js and npm versions to get the issue sorted out. The latest LTS version of node.js at the time of this writing is 16.13.0
and npm of 8.1.0
.
In general, if there’s a project on GitHub you are collaborating on, what could be the process to build an app?
- Clone the repository to your local dev environment,
- Run the
npm install
command to download node modules, and - Run the
npm run <command>
command to run the application
I know the steps identified above are exactly the same but similar. Depending on your case, you might use the node-gyp
package, which you are likely to meet the errors below.
Python
It doesn’t matter whether you are developing Python apps or not. The node-gyp
package has a direct dependency on Python, and you have to install it beforehand.
You might see the error message like below while running the command, npm install
.
NOTE: The default version of
node-gyp
is8.2.0
, which comes with node.js (LTS)14.13.0
, as the screenshot says.
It’s because Python is not installed on your machine. The solution is straightforward – install Python. Go to the Python website, download the latest version and install it. The newest version of Python at the time of this writing is 3.10.0
.
Once installed, run the following command to check whether Python is correctly installed or not.
Visual Studio 2019 Build Tools
Run the npm install
command again. Then, you’ll see the following error.
The node-gyp
package also depends on the C++ compiler, and your dev environment doesn’t have it yet. Therefore, you can install Visual Studio or Standalone Build Tools. In this section, let’s use the Standalone Build Tools for now. While installing, choose the «Desktop development with C++» workload option.
Since the download link currently offers the Visual Studio 2019 version at the time of this writing, you will be able to see the following screen after the installation.
The installed path is the following:
C:Program Files (x86)Microsoft Visual Studio2019BuildTools
Run the npm install
command again. Then you’ll get all the node modules installed with no error. However, if you still see the error like above, you should let npm know the version of Visual Studio like:
npm config set msvs_version 2019
Then, everything will go alright with the npm install
command.
NOTE: Depending on the timing, the Standalone Build Tools download link offers you the latest version of Build Tools. Therefore, you might not download Visual Studio 2019 version but the later version. If you download the later version than Visual Studio 2019, try the following section.
Visual Studio 2022 Build Tools
Recently, Visual Studio 2022 was released, and the Build Tool has also been upgraded to 2022. This page gives you the latest release of Build Tools. Choose the «Desktop development with C++» workload option, like before.
The installed location looks like this:
C:Program Files (x86)Microsoft Visual Studio2022BuildTools
But the node-gyp
version that comes with node.js 14.13.0
doesn’t support Visual Studio 2022. Therefore, you should update the npm version by running the following command:
npm install -g npm
Once updated, the npm version is changed from 8.1.0
to 8.1.4
.
In addition to that, the node-gyp
package also has been updated from 8.2.0
to 8.4.0
.
Now, run the npm install
command again, and it will properly install all the node modules. You can also override the Visual Studio version like:
npm config set msvs_version 2022
Visual Studio 2022
In the previous two cases, you don’t need to install Visual Studio but the Build Tools workload. This time, let’s use Visual Studio 2022 itself. Visual Studio 2022 has a different installed location because it’s now running on the x64 mode natively.
C:Program FilesMicrosoft Visual Studio2022Community
Your node-gyp
version has already been updated to 8.4.0
. Hence, once you complete installing Visual Studio 2022, running the npm install
command won’t cause an issue. Then, of course, you can force the Visual Studio version like below:
npm config set msvs_version 2022
NOTE: In this post, I just use the Visual Studio Community Edition. But you can use Professional or Enterprise Edition.
Long Path Issue
It’s not related to the node-gyp
package, but you will frequently see this issue while developing the node.js app on Windows. The long path issue on Windows OS is now resolved on Windows 11 through Local Group Policy Editor.
Once open Local Group Policy Editor, navigate to «Local Computer Policy» ➡️ «Computer Configuration» ➡️ «Administrative Templates» ➡️ «System» ➡️ «File System» and open the «Enable Win32 long paths» item.
This value is «Not Configured» as default. Enable it.
Then, you don’t have to suffer from the long path issue any longer.
So far, we’ve walked through the node-gyp
issue while working with the node.js app on Windows 11. I hope this approach helps.
- Главная
- Front-end
- Установка 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: `node—gyp 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: Can‘t 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 Блог Ирины Соколовской
I was trying to install node module printer «npm install printer» and got few errors while trying few solutions that I found in different blogs, forums and stackoverflow sites.
I would like to share what worked for me at the end.
[] Uninstall all Microsoft Visual C++ except the latest one.
I have installed 2015 — https://www.microsoft.com/en-us/download/details.aspx?id=49983 (Microsoft Visual C++ Build Tools 2015 Technical Preview)
npm config set msvs_version 2015 --global
[] Install Python version < 3.0.
I have Python 2.7.11 installed at C:Python27 and added to windows path.
https://www.python.org/downloads/release/python-2711/
npm config set python python2.7 --global npm config set python C:Python27python.exe --global
If you have windows 32 bit machine, run this:
set VCTargetsPath=C:Program FilesMSBuildMicrosoft.Cppv4.0v140
If you have windows 64 bit machine, run this:
set VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0v140
After those steps I opened new CMD window and run «npm install printer —save» and it installed perfectly this time.
[] Some of the errors I was getting were:
1.
https://github.com/tojocky/node-printer/issues/121
MSBUILD : error MSB3428: Could not load the Visual C++ component «VCBuild.exe». To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [C:_projectsnode projectsprinternode_modulesprinterbuildbinding.sln] gyp ERR! build error
2.
vcbuild.exe : error VCBLD0010: Project ‘C:_projectsnode projectsprinttestnode_modulesprinterbuildnode_printer.vcproj’ requires upgrade. Use ‘vcbuild /upgrade’ or ‘devenv /upgrade’ to upgrade the project.
3.
vcbuild.exe : error VCBLD0010: Project ‘config’ requires upgrade. Use ‘vcbuild /upgrade’ or ‘devenv /upgrade’ to upgrade the project.
4.
npm ERR! [email protected] install: ‘node-gyp rebuild’npm ERR! Exit status 1npm ERR!npm ERR! Failed at the [email protected] 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 printer package,npm ERR! not with npm itself.npm ERR! Tell the author that this fails on your system:npm ERR! node-gyp rebuildnpm ERR! You can get information on how to open an issue for this project with:npm ERR! npm bugs printernpm ERR! Or if that isn’t available, you can get their info via:npm ERR! npm owner ls printernpm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:npm ERR! C:_projectsnode projectsprinttestnpm-debug.log
References:
Check these urls for more ideas:
1> https://github.com/tojocky/node-printer/issues/121
2> https://github.com/nodejs/node-gyp/issues/629#issuecomment-197413477
3> https://www.robertkehoe.com/2015/03/fix-node-gyp-rebuild-error-on-windows/
4> http://stackoverflow.com/questions/14278417/cannot-install-node-modules-that-require-compilation-on-windows-7-x64-vs2012