npm install that requires node-gyp fails on Windows - node.js

I have a NPM project that uses bufferutils and utf-8-validate, both requiring node-gyp to install them. When I do npm install, I get following error:
> bufferutil#1.2.1 install C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil
> node-gyp rebuild
C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil {git}{hg}
{lamb} if not defined npm_config_node_gyp (node "C:\Users\Marek\AppData\Roaming\npm\node_modules\npm\bin\node-g
yp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
bufferutil.cc
C:\Users\Marek\.node-gyp\5.1.1\include\node\v8.h(18): fatal error C1083: Cannot open include file: 'stddef.h':
No such file or directory [C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil\build\bufferutil.vcx
proj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Marek\AppData\Roaming\npm\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Marek\\AppData\\Roaming\\npm\\node_modules\\
npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil
gyp ERR! node -v v5.1.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
npm WARN install:bufferutil#1.2.1 bufferutil#1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil#1.2.1 Exit status 1
Previously it failed because of Python 2.7 not installed, now it is this. It's causing me headaches. What should I do about this?

The answer below stands for a manual installation, but there is a much simpler way : the automatic install.
Open Powershell as admin and run npm install -g windows-build-tools.
The install takes time but it worked like a charm for me !

I found this brilliant solution on GitHub:
Your OS MUST be Windows
Check that python is in your path by writting python --version in the console. If not then
Download python 2.7 (I recommend chocolatey (choco install python2 -y)) and add python.exe to your PATH variable.
Aren't you on Windows 7? Skip 5 and 6.
Check that you have .NET 4.5.1+ installed. If not then
Download and install .NET 4.5.1 (.NET 4.5.2 will also work just fine)
Download Microsoft Visual C++ Build Tools 2015 Technical Preview
Use custom install. Install the Windows 8.1 SDK if you haven't already. Apparently, it doesn't matter what OS you're on. You just need the Windows 8.1 SDK.
Set the npm config variable msvs_version to 2015: npm config -g set msvs_version 2015
Do npm i in what-ever project with node-gyp as a dependency without seeing weird error messages
My nightmares are gone!

I couldn't find my solution anywhere else, so thought I'd share.
Running node v10.16.3 on Windows 10
Install windows-build-tools -
npm install --global --production windows-build-tools
Set the python path explicitly in C:\Users[your username].npmrc - In my case, this is like so:
python=c:\users\akeel\.windows-build-tools\python27\python

Started Working For Me
Nothing work for me (installed msvs_version 2017,2015)
Noticed
node-gyp error comes from python path and msvsc path
npm config list
Output (set correct installed path and msvs)
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.12.0 node/v12.9.0 win32 ia32"
; userconfig C:\Users\balaji\.npmrc
init-author-name = "Balaji"
init-license = "MIT"
msvs_version = "2017"
node_gyp = "C:\\Users\\balaji\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
python = "C:\\Users\\balaji\\.windows-build-tools\\python27/python.exe"
; globalconfig C:\Users\balaji\AppData\Roaming\npm\etc\npmrc
; builtin config undefined
prefix = "C:\\Users\\balaji\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files (x86)\nodejs\node.exe
; cwd = G:\all clients project\2020\anware
; HOME = C:\Users\balaji
; "npm config ls -l" to show all defaults.
To Set globaly(eg)
npm config -g set msvs_version 2015
To Set localy (eg)
npm config set msvs_version 2015
Path correction
npm config set python /path/to/executable/python
for those who Not installed yet(it install msvsc and python)
npm install -g windows-build-tools
after install check above givn tips such as path and version everything
happy coding....
detail info updated
https://stackoverflow.com/a/68630586/11624647

I was having this issue when updating from an older version of node to node v12. There was a particular issue with bcrypt library. I just uninstalled v12 and installed v10 and everything worked.

Found a solution here: https://spin.atomicobject.com/2019/03/27/node-gyp-windows/
I had to install Windows Build Tools 2015 and then set Node to use it.
Here are the commands I've used:
npm install --global --production windows-build-tools --vs2015
npm config set msvs_version 2015 –global

Using WSL works for me (windows 10 users only)
those who dont know what WSL is simply Linux command shell in windows
just follow this guide to install WSL https://wiki.ubuntu.com/WSL
and install nodejs and npm my using commands
sudo apt-get install nodejs npm -y

Related

Facing problems in installing brain.js [duplicate]

I want to run this project : https://github.com/adonis-china/adonis-adminify
When I run npm install, there exist error :
> sqlite3#3.1.13 install C:\laragon\www\adonis-admin\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3#3.1.13 and node#10.15.0 (node-v64 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3#3.1.13 and node#10.15.0 (node-v64 ABI) (falling back to source compile with node-gyp)
gyp ERR! gypfind VS
gyp ERR!ERR! find VSfind VS
msvs_version not set from command line or npm config
gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config
VCINSTALLDIR not set, not running in VS Command Prompt
gyp gypERR! ERR! find VSfind VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp checking VS2019 (16.2.29230.47) found at:
gypERR! find VSERR! checking VS2019 (16.2.29230.47) found at:
gyp find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
ERR!gyp find VS ERR! "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
gypfind VS ERR! - "Visual Studio C++ core features" missing
gyp ERR!find VS - "Visual Studio C++ core features" missing
find VSgyp could not find a version of Visual Studio 2017 or newer to use
gypERR! ERR!find VS could not find a version of Visual Studio 2017 or newer to use
find VS looking for Visual Studio 2015
gyp gyp ERR!ERR! find VSfind VS looking for Visual Studio 2015
- not found
gyp gyp ERR!ERR! find VSfind VS - not found
not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR!gyp ERR!find VS find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp gypERR! ERR!find VS
gypfind VS **************************************************************
gypERR! ERR!find VS find VS **************************************************************
You need to install the latest version of Visual Studio
gypgyp ERR! ERR!find VS find VS You need to install the latest version of Visual Studio
including the "Desktop development with C++" workload.
gypgyp ERR!ERR! find VS find VS including the "Desktop development with C++" workload.
For more information consult the documentation at:
gyp ERR!gyp find VS For more information consult the documentation at:
ERR!gyp ERR! find VSfind VS https://github.com/nodejs/node-gyp#on-windows
https://github.com/nodejs/node-gyp#on-windows
gyp gyp ERR!ERR! find VS **************************************************************
find VSgyp **************************************************************
gypERR! find VS
ERR! find VS
gyp gypERR! ERR!configure error
configure errorgyp
ERR! stackgyp Error: Could not find any Visual Studio installation to use
gypERR! stackERR! Error: Could not find any Visual Studio installation to use
stackgyp at VisualStudioFinder.fail (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
ERR!gyp stack at VisualStudioFinder.fail (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
ERR! gypstack at findVisualStudio2013 (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16)
gypERR! ERR!stack at findVisualStudio2013 (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16)
stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:344:14)
gypgyp ERR! stack at findVisualStudio2015 (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14)
gypERR! ERR! stackstack at regSearchKeys (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:365:16)
at VisualStudioFinder.findVisualStudio2013 (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:344:14)
gyp gypERR! ERR!stack stack at regGetValue (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7)
at findVisualStudio2015 (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14)
gypgyp ERR!ERR! stackstack at C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp at regSearchKeys (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:365:16)
gyp ERR! ERR!stack at ChildProcess.exithandler (child_process.js:301:5)
gypstack at regGetValue (C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7)
ERR! gypstack at ChildProcess.emit (events.js:182:13)
gypERR! ERR! stack at C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
stack at maybeClose (internal/child_process.js:962:16)
gyp gypERR! ERR! System Windows_NT 10.0.17134
stackgyp at ChildProcess.exithandler (child_process.js:301:5)
ERR!gyp commandERR! "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Chelsea\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\laragon\\www\\adonis-admin\\node_modules\\sqlite3\\lib\\binding\\node-v64-win32-x64\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\\laragon\\www\\adonis-admin\\node_modules\\sqlite3\\lib\\binding\\node-v64-win32-x64" "--python=C:\\Users\\Chelsea\\.windows-build-tools\\python27\\python.exe"
gypstack at ChildProcess.emit (events.js:182:13)
gypERR! ERR!cwd C:\laragon\www\adonis-admin\node_modules\sqlite3
gypstack ERR! at maybeClose (internal/child_process.js:962:16)
node -v v10.15.0
gypgyp ERR!ERR! Systemnode-gyp -v Windows_NT 10.0.17134
v5.0.3
gypgyp ERR!ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Chelsea\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\laragon\\www\\adonis-admin\\node_modules\\sqlite3\\lib\\binding\\node-v64-win32-x64\\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\\laragon\\www\\adonis-admin\\node_modules\\sqlite3\\lib\\binding\\node-v64-win32-x64" "--python=C:\\Users\\Chelsea\\.windows-build-tools\\python27\\python.exe"
not okgyp
ERR! cwd C:\laragon\www\adonis-admin\node_modules\sqlite3
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\laragon\www\adonis-admin\node_modules\sqlite3\lib\binding\node-v64-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\laragon\www\adonis-admin\node_modules\sqlite3\lib\binding\node-v64-win32-x64 --python=C:\Users\Chelsea\.windows-build-tools\python27\python.exe' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\laragon\www\adonis-admin\node_modules\sqlite3\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
node-pre-gyp ERR! System Windows_NT 10.0.17134
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\laragon\\www\\adonis-admin\\node_modules\\sqlite3\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\laragon\www\adonis-admin\node_modules\sqlite3
node-pre-gyp ERR! node -v v10.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Chelsea\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\laragon\www\adonis-admin\node_modules\sqlite3\lib\binding\node-v64-win32-x64\node_sqlite3.node --module_name=node_sqlite3 --module_path=C:\laragon\www\adonis-admin\node_modules\sqlite3\lib\binding\node-v64-win32-x64 --python=C:\Users\Chelsea\.windows-build-tools\python27\python.exe' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3#3.1.13 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3#3.1.13 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:\Users\Chelsea\AppData\Roaming\npm-cache\_logs\2019-09-10T22_53_41_072Z-debug.log
How can I solve the error?
TL;DR
Use the Visual Studio Installer to get the Desktop development with C++ workload in one of the Visual Studio versions you have installed in your machine:
Reason/Details
Reading through the log, the main error is due to this:
msvs_version not set from command line or npm config
After this one you find a few of these:
"Visual Studio C++ core features" missing
And later:
You need to install the latest version of Visual Studio including the "Desktop development with C++" workload.
For more information consult the documentation at:
VS https://github.com/nodejs/node-gyp#on-windows
Finally:
Could not find any Visual Studio installation to use
So to solve the problem, you just need to get "Desktop development with C++" workload.
If you have a Visual Studio version installed
open Visual Studio Installer (Win + search for it)
on the list displayed with all Visual Studio Installations you have in your PC, press the Modify button of one of them (preferably the latest version)
on the Workloads grid/list select the checkbox with Desktop development with C++
Press one of the Install buttons
gyp will then find that version and use it:
gyp info find Python using Python version 3.8.1 found at "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\python.exe"
gyp info find VS using VS2019 (16.4.29709.97) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\
With NO Visual Studio installed
The following solutions assume you have node installed. Disclaimer: I did not test any of them, but I appreciate everyone that reported them solving this issue.
Alternative 0: before installing additional software
As kaulshapranav wrote in a couple of comments, slightly shortened/rephrased:
windows-build-tools installation log mentions this tools package is deprecated and is already included with node. It corrupts my anaconda installation by installing a separate python 2.7 (...); updating npm version from 6 -> 8 solved the issue.
npm comes with node, so the solution: update your node/npm version. However, if you need to retain specific versions, nvm (notice the v) allows to change between them: simple tutorial on how to use nvm.
Alternative 1
As Hamid Jolany's answer suggests, on an admin shell, simply install the build tools package globally (node-gyp README):
npm i -g windows-build-tools
Alternative 2
Ragavan's idea/answer from a similar thread:
verify if you have VS build tools by running npm config get msvs_version (if you have, skip to step 4 and attempt setting the environment variables)
if not installed, get the VS build tools latest version exe and install it (Ragavan's idea was with or Microsoft Build Tools 2015)
run npm config set msvs_version 2019 --global (or npm config set msvs_version 2015 --global according to Ragavan's idea)
Possibly optional: set the VCTargetsPathenvironment variable (Win + search for var) to the appropriate path (e.g. C:\Program Files (x86)\MSBuild\Microsoft\Portable\v5.0) or through Run as Admin terminal, as in Ragavan's idea with the 2015 Build Tools:
set VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140"
or in Powershell: $env:VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
Side notes:
a previous error might be resolved by installing Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019;
you might also want to restart after installing any of the above
Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).
Full Guidance in GitHub
To get this to work with Visual Studio 2022, I had to run:
npm config set msbuild_path "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe"
Use the following command before npm install:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
Changing \Enterprise\ to \Community\ worked for me.
I solved the issue with npm install -g node-gyp, then npm install.
Visual Studio Installer -> Modify Installed(Visual Studio Community 2019) -> Workloads(tab) -> [x] Desktop development with C++ -> Install
I finally solved it on my end
here is how I did it
run this command on visual studio: npm config get msvs_version( mine was saying undefined)
then I run npm config set msvs_version 2022 --global(I was not seeing undefined anymore)
Then run: npm install. then I run my automation but this time I was seeing (Miscellaneous Warning SELF_SIGNED_CERT_IN_CHAIN:)
then I run set NODE_TLS_REJECT_UNAUTHORIZED=0 and voila!!! it is working
I hope this helps .it was really annoying because some of my automation file was not working
Start by running this (you can edit the year and type of VS you have i.e 2022 and community)
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
Afterwards Run npm install -g node-gyp, then npm install.
Make sure all this is done within the project.
Try
npm install --global --production windows-build-tools --vs2015
It worked for me.
I only installed C++ build tools (refer picture) through Visual Studio Build Tools (2019 version). No other steps required for me on Win 10 Pro.
I tried to solve this issue using npm i -g windows-build-tools but not working then I install Visual Studio Build Tools desktop development with c++ tools
and finally successfully solved this issue
Cool!
Following old answers, npm i -g windows-build-tools is an easy and successful answer. But windows-build-tools exists a bug with issue: https://github.com/felixrieseberg/windows-build-tools/issues/244. Try and do it!
just update module gulp-sass to the latest version, add sass module to the package.json and write
const sass = require('gulp-sass')(require('sass'));
to the gulpfile.js to get rid off node-gyp.
i fixed by install vscode 2017 and Desktop development with C++(im install with default optinal select download. not sure if not select default optinal see image.
will error or not) with vsInstaller and set (please set with Developer Command Prompt for VS 2017) use command with your directory project not global example: cd "G:\work\projectA"
set msbuild_path by command:
npm config set msbuild_path "G:\vs 2017\MSBuild\15.0\Bin\MSBuild.exe" (im setup with drive G by initiate because my c drive is full)
set msvs_version by command:
npm config set msvs_version 2017 (before im use 2015 can't work)
im check node-gyp can work? by command
node-gyp configure if not err. congat you can use npm install now
note: you can check local value by npm config get ....
If you are still facing issues with installation of windows build
tool. you can also install it manually without using command prompt.
you can install windows build tools through official site or by this also here.
1: Windows Build Tool Complete Package : Here
2: Official site to download: Here
I got the same issue and was confused about what I should do. I searched the whole web and still no solution.
What I decided to do is that
npm outdated
When you try this command you will see all the versions basically and in detail you understand which version is needed, which is the latest version at that moment, and which version your project json file has.
C:\GitHub\portfolio>npm outdated
Package Current Wanted Latest Location Depended by
babel-plugin-styled-components 1.13.3 1.13.3 2.0.7 node_modules/babel-plugin-styled-components portfolio
babel-preset-gatsby 1.14.0 1.14.0 2.21.0 node_modules/babel-preset-gatsby portfolio
eslint 7.32.0 7.32.0 8.22.0 node_modules/eslint portfolio
gatsby 3.14.6 3.14.6 4.21.1 node_modules/gatsby portfolio
gatsby-plugin-google-analytics 3.14.0 3.14.0 4.21.0 node_modules/gatsby-plugin-google-analytics portfolio
gatsby-plugin-image 1.14.2 1.14.2 2.21.0 node_modules/gatsby-plugin-image portfolio
gatsby-plugin-netlify 2.11.1 2.11.1 5.0.1 node_modules/gatsby-plugin-netlify portfolio
gatsby-plugin-offline 3.10.2 3.10.2 5.21.0 node_modules/gatsby-plugin-offline portfolio
gatsby-plugin-react-helmet 3.10.0 3.10.0 5.21.0 node_modules/gatsby-plugin-react-helmet portfolio
gatsby-plugin-sitemap 2.12.0 2.12.0 5.21.0 node_modules/gatsby-plugin-sitemap portfolio
gatsby-plugin-styled-components 3.10.0 3.10.0 5.21.0 node_modules/gatsby-plugin-styled-components portfolio
gatsby-remark-prismjs 3.13.0 3.13.0 6.21.0 node_modules/gatsby-remark-prismjs portfolio
gatsby-transformer-remark 4.11.0 4.11.0 5.21.0 node_modules/gatsby-transformer-remark portfolio
husky 6.0.0 6.0.0 8.0.1 node_modules/husky portfolio
lint-staged 10.5.4 10.5.4 13.0.3 node_modules/lint-staged portfolio
react 17.0.2 17.0.2 18.2.0 node_modules/react portfolio
react-dom 17.0.2 17.0.2 18.2.0 node_modules/react-dom portfolio
Then after I figure out all reds to yellow, all the packages are installed and ready to use.
Now try it again.
Worked for me; it should work for you too.
If all of above doesn't help, verify that your command prompt is not customized
E.g., if you're using MS Windows and you use doskey to add aliases on startup.
The tools that look for Visual Studio installation get mixed up if this happens.
You can test if this is the case by manually opening a new command prompt and verifying it has bare minimum output, such as
Microsoft Windows ...
(c) ...
$Path>
My solution was combination of all previous fixes:
Install Visual Studio 2017 (https://my.visualstudio.com/Downloads?q=Visual%20Studio%202017 - It will ask you to log in, choose Build Tools for Visual Studio 2017 (version 15.9))
When installing, choose Desktop development with C++ (or similar name)
In C:\Users\<your_username>\ open .npmrc file and delete everything inside, save and close file
Now you need to set environment variables. If you don't know how to do it google it.
3.1 In section user variables click new, set variable name as VCINSTALLDIR and variable value as C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\ (note that path can be different in your case but make sure that VC path is provided).
In terminal do:
4.1 npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
(note that location can be different in your case, but make sure you are specifying correct path to MSBuild.exe including MSBuild.exe)
4.2 npm config set msvs_version 2017
Now you can run build or install. When I did all the steps, I didn't get error.
For me worked the trick of using of npm 14.14.0
gyp started to work perfectly well
ps for my project I also installed Visual Studio Build Tools (2022 version) with Desktop development with C++ workload and Python311 with configuring its PATH in win10
Ensure that you have the latest npm installed.
npm install -g npm#latest
I also faced the same issue, what I did is I reinstall the nodejs

How to force npm to use different node-gyp version when installing packages?

I am running Node 16.13.2 LTS with Visual Studio 2022. During the installation of a package, node-gyp is triggered and fails.
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node build.js || nodejs build.js
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp#8.3.0
npm ERR! gyp info using node#16.13.2 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.4 found at "C:\Users\ahboy\AppData\Local\Programs\Python\Python39\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Professional"
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
I went to do some research and found out that node-gyp#8.3.0 does not support VS 2022. Only version node-gyp#8.4 does. So I started to try to get npm to use node-gyp#8.4.0 but nothing works including this advice from node-gyp github page to install node-gyp globally and point the path in npmrc file.
So what can be done to force npm to use different node-gyp versions when installing packages?
I had a similar issue, what solved it for me was using nvm: Node Version Manager to install Node version 14, alongside the latest one. The repository I was cloning had a lot of dependencies. Also, I did not need to be on the bleeding edge of progress with the latest Node version.
Here is further resource on how to install and use nvm: Installing nvm on Windows.
If you installed latest node-gyp.
Check the version of node-gyp both in terminal (Powershell) and vscode terminal. One of them should be pointing to the 8.4 and another one to 8.3 So the terminal that you are running the app, looks like is not recognizing the path of 8.4 version.
What does the package.json in the package your installing show for the node-gyp dependency version? Also look at all subdependencies of those dependencies to see if any of those reference version 8.3. I've ran into this same issue as well on windows. If you can't get your version to update, you can also install visual studio build tools 2017 and set your msvs_version to 2017 and it should pick that up for you. No need to install the full vs2017, just the build tools will do fine.
Declare your dependency on the newer version of node-gyp in your package.json file. Add this to your dependency block:
"node-gyp" : "^8.4.1",
I did exactly this about an hour ago to get our github actions CI tests working since the switch of 'windows-latest' became windows server 2022.

node-gyp configure got "gyp ERR! find VS"

I am trying to start about node c/c++ add-on. the node-gyp command got error
I have installed vs2019, my command is
node-gyp configure --msvs_version=2019
the verbose output is
gyp info it worked if it ends with ok
gyp info using node-gyp#5.0.3
gyp info using node#10.16.0 | win32 | x64
gyp info find Python using Python version 2.7.15 found at "C:\Users\seact\.windows-build-tools\python27\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio version 2019
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "C:\Program Files (x86)\Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS valid versions for msvs_version:
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (D:\Program Files\node-win-x64\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at findVisualStudio2013 (D:\Program Files\node-win-x64\node_modules\node-gyp\lib\find-visualstudio.js:74:16)
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\Program Files\node-win-x64\node_modules\node-gyp\lib\find-visualstudio.js:344:14)
gyp ERR! stack at findVisualStudio2015 (D:\Program Files\node-win-x64\node_modules\node-gyp\lib\find-visualstudio.js:70:14)
gyp ERR! stack at regSearchKeys (D:\Program Files\node-win-x64\node_modules\node-gyp\lib\find-visualstudio.js:377:20)
gyp ERR! stack at regGetValue (D:\Program Files\node-win-x64\node_modules\node-gyp\lib\util.js:54:7)
gyp ERR! stack at D:\Program Files\node-win-x64\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:301:5)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "D:\\Program Files\\node-win-x64\\node.exe" "D:\\Program Files\\node-win-x64\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--msvs_version=2019"
gyp ERR! cwd D:\Projects\learn_node_ext
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
You do not have to install Visual Studio, just install the windows build tools:
run CMD as Admin
run npm install --g --production windows-build-tools
This should fix that.
There are 2 aspects to this error. Now in 2022, if you have installed Visual Studio 2022, even after installing Desktop development with C++ or the build tools it still wont work.
Few things you need to do even after installation.
npm config get python should be set to Python 3.x
--> npm config set python C:\Python310\python.exe
npm config get msvs_version should be using 2022
--> npm config set msvs_version 2022 --global
Additionally you can set
npm config set msbuild_path "C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe"
your VCINSTALLDIR ENV variable should be set to C:\Program Files\Microsoft Visual Studio\2022\Community\VC
In some case it still wont work, then you can follow the additional steps, visit the folder of your Node.js exe installation, should be same even for an nvm node version; https://github.com/nodejs/node-gyp/blob/master/docs/Updating-npm-bundled-node-gyp.md
cd "C:\Program Files\nodejs"
cd node_modules\npm\node_modules\#npmcli\run-script
npm install node-gyp#latest
Open your Visual Studio & then in 'search box' search VS 2019 C++ x64/x86 build tools and install then search Desktop development with C++ install it. Hope this helps.
If you are using Chocolatey, install the following:
choco install visualstudio2019buildtools visualstudio2019-workload-vctools
It is because the C++ build tools are not installed. It can be solved by installing VS 2019 C++ x64/x86 build tools in Visual Studio installer:
Your powershell is running probably in constrained mode.
See this thread: how to change PowerShell mode to fulllanguage mode from constrained mode?
Downloading the latest Visual Studio build Tools
https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
and running the following command in the 'Program Files (x86)\Microsoft Visual Studio\2017\BuildTools' Directory
npm install --g --production windows-build-tools
and Installing node-gyp in the current directory
npm install node-gyp
Worked For me on Windows 10
for more, please visite the official node-gyp installation guide
I had to set python path for npm even though I had python on my PATH.
npm config set python /path/to/executable/python
then try npm install again
It should be a npm package bug of windows-build-tools.
Step 1: Be sure you installed Visual Studio Code
Step 2: Search %temp% under window search bar (Copy %temp% then press windows button + Ctrl V)
Step 3: Create 'dd_client_.log.txt' and enter 'Closing installer. Return code: 3010.'
Now you should be able to finish the whole process with npm install --global windows-build-tools
My working environment: Visual Studio Enterprise 2022, Python 3.11, and Node v18.13.0. I did everything according to steel's answer, but still got errors. Looks like npm config set msvs_version 2022 --global doesn't help.
I finally got it working by adding an Environment Variable - GYP_MSVS_VERSION and setting it to 2022.
Download Visual Studio Community Edition
Run the executable
Choose the options as below.
and it should solve the issue.
In case if someone still has the visual studio installation required error after going through all the steps mentioned above. I had this issue when I was trying to run an electron application. The solution for my issue was simply adding the visual studio to the environment variables after going through all the above steps.
To set the path run the following command on cmd (if possible as admin):
setx VCTargetsPath “C:\Program Files (x86)\MSBuild\15.0"
Note: the path for my visual studio was as in the above. you may have to change it according to your installation.
The software versions I was using are as follows:
nodejs : 14.17.0
OS : windows10 64-bit
Python : 2.7.15 (installed default with node js)
Visual studio : community edition 2019
some of the other things to check is to make sure the python version, msvs_version are set to the correct versions in the npm config.
Instead of running 'npm install', run 'npm update' directly in the folder. This solved my issue.
Same issue after upgrading to latest node LTS version. This did the trick for me:
removed node_modules folder
removed package-lock.json file
npm install
TLDR: Installing the latest LTS version of Node.js via Windows Installer worked for me somehow. Latest LTS Version
I tried all the answers from this thread and some other articles as well but nothing was working for me. After spending 6+ hours on this issue, I saw this note on Windows-Build-Tools Github page.
Please note that the official Node.js for Windows installer can now automatically install the required tools. That's likely a much better option than the module listed here (windows-build-tools).
So I installed the latest LTS version of Node.js via Windows Installer from Node js website as shown in the above image and it worked somehow.
Solution that worked for me was to install latest Visual Studio Build Tools and then execute following command, taken from node-gyp installation instructions here:
npm config set msvs_version 2017
npm install --g --production windows-build-tools
on my computer works with the next commands
npm install --g --production windows-build-tools
npm install node-gyp
npm audit fix
npm install node-phpass
Same issue faced by me with VS 2022 community edition, node 15.x, python 3.10
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
Issue was due to non-compatible Node version 15.x.x to gyp
and, successfully resolved with downgrading node to 14.17.3 version.
Thanks
I had the same problem before, thanks C. Szabo's answer.
node-gyp use Powershell script to find Visual Studio. You should check
$ExecutionContext.SessionState.LanguageMode
in Powershell. If it return 'ConstrainedLanguage', node-gyp will fail to find Visual Studio. Change _PSLockdownPolicy in register can fix this problem, see this answer. (Don't forget to reboot Windows)
I also encountered this error. After trying all the suggestions I could find and spending 2 days trying to resolve it, I finally found out the reason it wasn't working for me was that in my build environment I didn't have ProgramData env variable defined. After adding "ProgramData": "C:\ProgramData" everything started working like a charm.
When this env var is not defined, for whatever reason, query2.EnumAllInstances() in Find-VisualStudio.cs returns empty enumeration.
Hopefully this will be useful for someone as well.
My friend creates the project and her node/npm versions are not compatible with mine.
So I try to upgrade my npm versions only. It's solved the problem.
But some of the dependencies are not working. So I update the node versions, as along with the npm version, will update. It solved almost all problems and errors.
You should find the correct compatible version of node and npm. Here you can find the node version and compatible npm version.
Make sure to check your npm version and node versions are compatible.

How can I change npm version while using create-react-app

I am trying to run create-react-app in my command line, and I keep getting this message:
"You are using npm 2.15.12 so the project will be boostrapped with an old unsupported version of tools."
I ran
sudo npm install npm#latest -g
to make sure I have the latest version of npm (I also tried "sudo npm install -g npm"). And when I run
npm -v
the output is "6.4.1"
I get a number of errors during the create-react-app process, but the app itself seems to work fine, "npm start" works and all the files seem to be in the right place, but I don't want to run into more errors down the road.
After a couple hours of searching, I can't find any other issues of create-react-app using the wrong version of npm. Is there a way to change the version of npm being used while using create-react-app?
The hidden code snippet below lists the errors that I get during create-react-app. I feel like they might be due to using the outdated version of npm.
node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.17/fse-v1.0.17-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents#1.0.17 and node#11.0.0 (node-v67 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.17/fse-v1.0.17-node-v67-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents#1.0.17 and node#11.0.0 (node-v67 ABI) (falling back to source compile with node-gyp)
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/myuser/node_modules/npm/node_modules/node-gyp/lib/build.js:285:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 17.4.0
gyp ERR! node -v v11.0.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute
Solved. I believe I had some extra node files floating around (potentially from installations I didn't do correctly). I decided to do a complete removal of nvm/node/npm and get a fresh install (I am on a mac).
To remove nvm and node, I removed all node and node_package files in /usr (there are quite a few tutorials on where to find node files and folders). I followed the guides but also had a few exceptions. I had a folder that was simply named "n" that had some node files in it (which I then deleted) and then had to show my hidden files to find an ".nvm" folder in /users/userName. I deleted the ".nvm" folder and was finally able to completely get rid of nvm, node and npm.
After I freshly installed nvm and node (I had to remake the .nvm folder for the nvm install script to work), the create-react-app command is working correctly.
You need to update your npm version using this:
npm install -g npm
Please note that this command will remove your current version of npm. Make sure to use
sudo npm install -g npm
if on a Mac.

NodeJS - Error installing with NPM

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Windows\system32>npm install caress-server
npm http GET https://registry.npmjs.org/caress-server
npm http 304 https://registry.npmjs.org/caress-server
npm http GET https://registry.npmjs.org/jspack/0.0.1
npm http GET https://registry.npmjs.org/buffertools
npm http 304 https://registry.npmjs.org/jspack/0.0.1
npm http 304 https://registry.npmjs.org/buffertools
> buffertools#2.0.1 install C:\Windows\system32\node_modules\caress-server\node_
modules\buffertools
> node-gyp rebuild
C:\Windows\system32\node_modules\caress-server\node_modules\buffertools>node "G:
\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-
gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at failNoPython (G:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:101:14)
gyp ERR! stack at G:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:64:11
gyp ERR! stack at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "G:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\
bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\system32\node_modules\caress-server\node_modules\buffert
ools
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! buffertools#2.0.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the buffertools#2.0.1 install script.
npm ERR! This is most likely a problem with the buffertools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls buffertools
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\\nodejs\\\\node.exe" "G:\\nodejs\\node_modules\\npm\\bin\\n
pm-cli.js" "install" "caress-server"
npm ERR! cwd C:\Windows\system32
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Windows\system32\npm-debug.log
npm ERR! not ok code 0
C:\Windows\system32>
I am installing a certain NodeJS script - Caress. But i am not unable to. I am using Windows 8.1, can anyone tell me what is the problem i am facing, and why is this installation not working. There seems to be a problem with the buffertools dependency, thats far as i can think. Dont know how maybe fix this?
If i download the build from github and place it in node-modules, nothing seems to work. when i try to start, using npm start, or during implementation either.
G:\nodejs\node_modules\caress-server>npm install
G:\nodejs\node_modules\caress-server>npm start
> caress-server#0.1.1 start G:\nodejs\node_modules\caress-server
> node examples/server.js
info - socket.io started
module.js:340
throw err;
^
Error: Cannot find module './build/Release/buffertools.node'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (G:\nodejs\node_modules\caress-server\node_modules\buf
fertools\buffertools.js:16:19)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
npm ERR! caress-server#0.1.1 start: `node examples/server.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the caress-server#0.1.1 start script.
npm ERR! This is most likely a problem with the caress-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node examples/server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls caress-server
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\\nodejs\\\\node.exe" "G:\\nodejs\\node_modules\\npm\\bin\\n
pm-cli.js" "start"
npm ERR! cwd G:\nodejs\node_modules\caress-server
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! G:\nodejs\node_modules\caress-server\npm-debug.log
npm ERR! not ok code 0
G:\nodejs\node_modules\caress-server>
As commented below you may not need to install VS on windows, check this out
https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245
UPDATED 02/2016
Some npm plugins need node-gyp to be installed.
However, node-gyp has its own dependencies (from the github page):
UPDATED 09/2016
If you're using Windows you can now install all node-gyp dependencies with single command (NOTE: Run As Admin in Windows PowerShell):
$ npm install --global --production windows-build-tools
and then install the package
$ npm install --global node-gyp
UPDATED 06/2018
https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383
Delete your $HOME/.node-gyp directory and try again.
See full documentation here: node-gyp
NOTE: This is an old answer that applied to earlier versions of NodeJS. My sincere gratitude to these open source projects that responded to this issue and resolved this former pain.
Make sure you have all the required software to run node-gyp:
https://github.com/TooTallNate/node-gyp
You can configure version of Visual Studio used by node-gyp via an environment variable so you can avoid having to set the --msvs_version=2012 property every time you do an npm install.
Examples:
set GYP_MSVS_VERSION=2012 for Visual Studio 2012
set GYP_MSVS_VERSION=2013e (the 'e' stands for FREE 'express edition')
For the full list see
https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294
This is still painful for Windows users of NodeJS as it assumes you have a copy of Visual Studio installed and many end users will never have this. So I'm lobbying Joyent to the encourage them to include web sockets as part of CORE node and also to possible ship a GNU gcc compiler as part of NodeJS install so we can permanently fix this problem.
Feel free to add your vote at:
https://github.com/joyent/node/issues/8005#issuecomment-50545326
I encountered the issue with the error:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Here is what I was doing and what finally worked.
Disclaimer: I am just getting my hands into Node, Angular after many years in the Java, Linux world among others...
Environment Description: Windows 8.1 64-bit; Cygwin; cygwin bash shell
Command used that led to error: npm install -g karma
Error:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
Discovery: 'which python' on bash shell clearly shows '/usr/bin/python'. Now that is annoying!
Solution: This is only applicable to those using the environment similar to what I have, i.e. using cygwin and bash shell. Hope it helps in other environments as well but keep in mind that your kettle of tea may look a little different than mine.
Firstly, need to set the $PYTHON shell env variable in .bashrc using the explicit windows path to the python executable and not the unix like root path (/usr/bin) used by cygwin.
Secondly, and this one took a lot of trial/error and here's the gotcha! Cygwin installs python under /usr/bin (which is really a mirror of /bin on windows) with the version, i.e. (in my system) /usr/bin/python2.7.exe and then adds a link /usr/bin/python --> python2.7.exe. The problem is that gyp cannot follow this link and keeps giving the annoying error that it cannot find python even though you can find it just fine from the shell command line.
With the above background now add the following line to your .bashrc
export PYTHON="C:/cygwin64/bin/python2.7.exe (or whatever is the version on your system)"
Now source your .bashrc from your home directory (on cygwin)--> 'source .bashrc'
You should be fine now and gyp will find the python executable.
I hope this helps someone stumbling on the same or similar issue.
should be able get all node-gyp dependencies with chocolatey for Windows
choco install python2
choco install visualstudioexpress2013windowsdesktop
Setup JavaScript Environment
1. Install Node.js
Download installer at NodeJs website. You can download the latest V6
2. Update Npm
Npm is installed together with Node.js. So don't worry.
3. Install Anaconda
Anaconda is the leading open data science platform powered by Python. The open source version of Anaconda is a high performance distribution of Python. It can help you to manage your python dependency. You can use it to create different python environment in the futher if you want to touch with it.
Node-gyp only support >= Python 2.7 and < Python 3.0
So just install the 2.7 version
4. Install Node-gyp
You can install with npm:
$ npm install -g node-gyp
You will also need to install:
On Windows:
Option 1: Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator).
Option 2: Install tools and configuration manually:
Visual C++ Build Environment:
Option 1: Install Visual C++ Build Tools using the Default Install option.
Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.
💡 [Windows Vista / 7 only] requires .NET Framework 4.5.1
Launch cmd, npm config set msvs_version 2015
If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.
If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:
$ node-gyp --python C:/Anaconda2/python.exe
If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:
$ npm config set python C:/Anaconda2/python.exe
Future update for Node.js and npm
Download installer from their official website and direct install it. The installer will automatic help you to remove old files.
npm update npm
Future update for Python
conda update --all
Fixed with downgrading Node from v12.8.1 to v11.15.0 and everything installed successfully
gyp ERR! configure error gyp ERR! stack Error: Can't find Python
executable "python", you can set the PYT HON env variable.
This means the Python env. variable should point to the executable python file, in my case:
SET PYTHON=C:\work\_env\Python27\python.exe
For Cygwin users:
The python issue with using npm on an out-of-the-box Cygwin installation, is that node-gyp is giving a misleading error due to incomplete checking in the ../npm/node_modules/node-gyp/lib/configure.js code.
It's due to how Cygwin treats symbolic links. It doesn't do that properly in an out-of-the box installation. So the error messages from the above code become misleading, as it complains about the PYTHON path and not the existence of python.exe (or link of) file itself.
There are (at least) 2 ways to resolve this.
Installing the Cygwin package cygutils-extra and use winln.
Use native Windows CMD in Admin mode.
For (1) you can create a proper symlink from within Cygwin shell by doing these steps:
# To make the Cygwin environment treat Windows links properly:
# Alternatively add this to your `.bashrc` for permanent use.
export CYGWIN=winsymlinks:nativestrict
# Install Cygwin package containing "winln"
apt-cyg install cygutils-extra
# Make a proper Windows sym-link:
cd /cygdrive/c/cygwin64/bin/
winln.exe -s python2.7.exe python.exe
# Add PYTHON as a native Windows system wide variable (HKLM)
setx /M PYTHON "C:\cygwin64\bin\python"
(Also assuming you are running the Cygwin shell as Admin.)
Using apt-cyg is recommended and can be found in various forms on github.
For (2) the resolution for out-of-the-box Cygwin users is this:
# Open a native Windows CMD in Administrator mode and:
cd C:\cygwin64\bin\
mklink python.exe python2.7.exe
The result should look like this:
C:\cygwin64\bin>ls -al python*
lrwxrwxrwx 1 xxx xxx 13 Jun 2 2015 python -> python2.7.exe
lrwxrwxrwx 1 Administrators xxx 13 Aug 24 17:28 python.exe -> python2.7.exe
lrwxrwxrwx 1 xxx xxx 13 Jun 2 2015 python2 -> python2.7.exe
-rwxr-xr-x 1 xxx xxx 9235 Jun 2 2015 python2.7.exe
For windows
Check python path in system variable.
npm plugins need node-gyp to be installed.
open command prompt with admin rights, and run following command.
npm install --global --production windows-build-tools
npm install --global node-gyp
I was working on an old Vue 2.x project, at least 2 years old and deps were never updated. Reverting to Node v10.16.3 worked for me. Versions 14 and 12 did not work.
for me the solution was:
rm -rf ~/.node_gyp and
sudo npm install -g node-gyp#3.4.0
cd /usr/local/lib sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib
brew install gcc
npm install
I was installing appium by npm install -g appium and getting the same error on Windows 10.
Below command worked for me:
npm --add-python-to-path='true' --debug install --global windows-build-tools
https://github.com/felixrieseberg/windows-build-tools/issues/33
The question is already answered but these were not working in my case which is alpine Linux based OS so maybe this helps someone else.
I was also getting same error
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
So fix by single line just add this if you are working in Dockerfile or install it in OS
apk add --no-cache python nodejs
in ubuntu
sudo apt-get install python3.6
Note: Node version:8
install node-gyp and c++ compiler (gcc-c++).
npm install --global --production windows-build-tools

Resources