node gyp says build tools are undefined - node.js

I have installed the latest Visual Studio Build tools 2022 using these instructions: https://github.com/nodejs/node-gyp#on-windows
Windows 7 Enterprise x64
node -v v14.15.0
npm -v 6.14.5
node-gyp#9.1.0
This is my env:
This is my .npmrc file:
msvs_version=2017
msbuild_path=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe
Following the path to my build tools:
Following the MSBuild.exe I run this file and get:
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe
The error message when trying to install a package I get is:
npm install
Now it gets interesting: running gyp configure I don't get the same error:
I wonder what else can I do? I went trough countless threads and couldn't resolve this issue.
I have a machine with windows 10 on, and did the exact same procedure and it works. But here, the path to the build tools can't be found.

According to your screenshot you are using node-gyp 5.1.0, not 9.1.0, which is three years old at this point. So it not finding Visual Studio 2022, which was released last year, isn't unexpected.
You need to update your node-gyp version (or node, since node v14 is also old). If you update to a new version of node the installer will ask you if you want to install the build tools as well which is usually a good idea.
If you however want to upgrade your current node-gyp you can follow these steps, assuming node is installed in C:\Program Files\nodejs\ (taken from the node-gyp docs)
cd "C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\run-script"
npm install node-gyp#latest

Related

Error while installing quick.db in discord.js

This is my error. I constantly keep getting this error while trying to npm install quick.db
I am using Visual Studio Code, Node version 17.0.0, discord.js version 13.3.1, please help me, any help would be appreciated.
See the installation section of quick.db
Troubleshooting quick.db/better-sqlite3 installation
Make sure you're using nodejs v10.20.1 or later
Make sure you have node-gyp globally installed, including all of its dependencies. On Windows you may need to configure some things manually. Use npm ls node-gyp to make sure none of your local packages installed an outdated version of node-gyp that is used over the global one.
If you're using Electron, try running electron-rebuild
If you're using Windows, follow these steps. Do them in this order, and don't skip steps.
Install the latest of node 10, 12, or 14.
Install latest Visual Studio Community and Desktop Development with C++ extension.
Install latest Python.
Run following commands:
npm config set msvs_version 2019
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
Run npm install quick.db

CanĀ“t install Canvas (npm) on Windows

I installed GTK+2 as instructed here: https://github.com/Automattic/node-canvas/wiki/Installation---Windows
I installed libjpeg-turbo
I installed Visual Studio 2015 Community
I installed node-gyp: npm install -g node-gyp
But when I run node-gyp rebuild I get:
Cannot open source file: '..\src\Canvas.cc': No such file or directory ... my_project_folder\build\canvas.vcxproj]
And when I run npm install canvas I get:
node-gyp\src\win_delay_load_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type modifiers ... my_project_folder\node_modules\canvas\build\canvas.vcxproj]
I am almost giving up... so easy on mac and linux... this is hell
I was struggling with it too at some point, The issue was resolved for me by running the npm command using "MSBuild Command Prompt for VS2015" (which should have being installed as part of Visual Studio 2015 installation which you did)

npm install zmq issue

I am doing npm install zmq but stuck in strange error, please see below
C:\Users\Administrator>npm install zmq
MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available too
ls versions are "4.0".
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:
12)
googled but with no luck.
this is a fresh install on windows server 2012. and zmq is already installed using windows msi installer, but i want to use zmq under nodejs so doing npm.
i think msbuild is failing as node is assuming version 2 of .net framework, however installed .net version is 4.
can any one please guide me how to solve the issue - thanks
regards
zishan
right, thanks Gustav, I solved it by installing visual studio 2012.
first I changed the .net version from 4 to 2 by going to server manager, than I got another error where it says the system requires .net v2 sdk then i installed the sdk and finally visual studio 2012 of 5 gb.
problem solved but i am amazed why we have to install 5 gb of vs to make zmq work, can it not be done only by linking the required dll or library, why it requires whole bunch of vb files!
any ways its done.
"npm install zmq" requires Visual Studio 2013 or less, Python 2.7.x
If you have multiple versions of Visual Studio, run this script to make 2013 as default :-
set gyp_msvs_version=2013
or you can try this other official package - "zeromq"
with zeromq, you don't have to worry about all the binaries. It comes with pre-build binaries for win(32/64), Linux(64), OS X/ Darwin(64 bit)
"npm install zeromq"

Cannot install node modules that require compilation on Windows 7 x64/VS2012

I cannot install any of the modules that require compilation. All they fail with the following error:
MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". ...
My environment:
Windows 7 Enterprise x64, version 6.1.7601
node x86 0.8.16
npm 1.2.0
node-gyp 0.8.2
Visual Studio 2012 and numerous packages
Related environment variables:
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShel l\v1.0;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\tools;c:\tools\node
No INCLUDE, LIB, LIBPATH, etc.
I did a short investigation of the issue and figure out that with the following setup the manual compilation (calling VCBuild.exe and msbuild.exe directly) succeed for the manually cloned git://github.com/einaros/ws.git:
SET Configuration=Release
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcpackages
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
SET PATH=%SystemRoot%\system32;%PATH%
SET INCLUDE=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\include
SET INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
SET LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib
SET LIB=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\lib;%LIB%
SET MSBUILD="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
VCBuild.exe C:\Tools\node\ws\build\bufferutil.vcproj "Release|Win32" /useenv
VCBuild.exe C:\Tools\node\ws\build\validation.vcproj "Release|Win32" /useenv
%MSBUILD% build/binding.sln /verbosity:diagnostic /nologo /p:Configuration=Release;Platform=Win32
I've tried to call node-gyp with the same variables and it failed:
C:\!> git clone https://github.com/einaros/ws.git
C:\!> cd ws
C:\!\ws>node-gyp configure
...
C:\!\ws>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp#0.8.2
gyp info using node#0.8.16 | win32 | ia32
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=Win32' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\binding.sln]
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (c:\Tools\node\node_modules\node-gyp\lib\build.js:255:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\\Tools\\node\\\\node.exe" "c:\\Tools\\node\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\!\ws
gyp ERR! node -v v0.8.16
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok
Maybe you will have some ideas about it?
Thanks.
Try that - will set it globally:
npm config set msvs_version 2012 --global
To do it without VS2010 installation, and only 2012, set the msvs_version flag:
node-gyp rebuild --msvs_version=2012
npm install <module> --msvs_version=2012
as per #Jacob comment
npm install --msvs_version=2013 if you have the 2013 version
Update v3:
https://www.npmjs.com/package/windows-build-tools
npm install --global windows-build-tools
downloads and installs Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools are required to compile popular native modules. It will also install Python 2.7, configuring your machine and npm appropriately.
Update v2:
node-gyp updated their readme to include HOW-TO for windows
Original:
No need for the entire visual studio, you can download just the build tools
Microsoft Build Tools 2013 : http://www.microsoft.com/en-us/download/details.aspx?id=40760
run cmd to set global flag to use the 2013 version:
npm config set msvs_version 2013 --global
after this everything should be back to normal and your npm install / node-gyp rebuild will work
just add --msvs_version=2012
node-gyp rebuild --msvs_version=2012
or
node-gyp configure --msvs_version=2012
node-gyp build
I had the same issue when trying to install a package for Node.js. After some extensive googeling I found this walktrough: https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup
When I had followed these steps I could use "npm install" without any issues.
Thanks to #felixrieseberg, you just need to install windows-build-tools npm package and you are good to go.
npm install --global --production windows-build-tools
You won't need to install Visual Studio.
You won't need to install Microsoft Build Tools.
From the repo:
After installation, npm will automatically execute this module, which
downloads and installs Visual C++ Build Tools 2015, provided free of
charge by Microsoft. These tools are required to compile popular
native modules. It will also install Python 2.7, configuring your
machine and npm appropriately.
Windows Vista / 7 requires .NET Framework 4.5.1 (Currently not
installed automatically by this package)
Both installations are conflict-free, meaning that they do not mess with existing installations of Visual Studio, C++ Build Tools, or
Python.
on windows 8, it worked for me using :
npm install -g node-gyp -msvs_version=2012
then
npm install -g restify
After DAYS of digging, someone on IRC suggested that I try to use the
Windows 7.1 SDK Command Prompt
Shortcut (links to C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"). I think you MUST have the older 7.1 SDK (even on Windows 8.1) because the newer ones use msbuild.exe instead of vcbuild.exe which is what node-gyp wants even though it's twice as old as node at this point :/
Once in that prompt, I had to run the following to get x86 context because the compiler was throwing as error otherwise about architecture:
setenv.cmd /Release /x86
THEN I was able to successfully run npm commands that were trying to use node-gyp to recompile things.
I had the same isuee and did all the magic above, the only thing that did the magic for me is from https://github.com/atom/atom/issues/2435
"Because the --msvs_version=2013 is not passed to node-gyp when it's run by the build script. Set the GYP_MSVS_VERSION = 2013 env variable and it should work after."
Bang! it worked
On Windows
This helped me: (credits goes to) https://github.com/TooTallNate/node-gyp/wiki/Updating-npm%27s-bundled-node-gyp
I tried MINGW32, but with no success.
on cmd.exe
$ cd "C:\Program Files\nodejs\node_modules\npm"
$ npm install -g node-gyp#latest
For windows 8 64-bit, installing zmq and protobuf, the following worked for me:
Install Visual Studio 2012
On the command line:
SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf
I think the solution is to download
install Microsoft windows sdk for server 2008 with .net framework 3.5
or just install Visual studio 2008.
The issue is for windows builds node-gyp executes vcbuid.exe file, and for some reason it can't find it.
Thanks
Install Python 2.7 (not 3.x)
Add the path to the directory containing vcbuild.exe on your environment variable PATH
If you need vcbuild.exe get it here https://github.com/kin9puppy/vcbuildFixForNode
I had also a lot of problem to compile nodejs zmq.
For the problem with with vcbuild.exe, just add it to the PATH
For other problems I could compile just using Windows 7.1 SDK Command Prompt
(Menu Programs -> Microsoft Windows SDK v7.1 -> Windows 7.1 SDK Command Prompt)
And from the prompt:
npm install zmq
That's works :)
After a long struggle, I've switched my node architecture to x86 and it worked like a charm.
in cmd set Visual Studio path depending upon ur version as
Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%
Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%
Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%
In node-master( original node module downloaded from git ) run vcbuild.bat with admin privileges.
vcbild.bat will generate windows related dependencies and will add folder name Release in node-master
Once it run it will take time to build the files.
Then in the directory having .gyp file use command
node-gyp rebuild --msvs_version=2012 --nodedir="Dive Name:\path to node-master\node-master"
this will build all the dependencies.
I solved this problem on windows 8 and windows 10 pro with this tutorial.
I try a lot of times to solve this problem with many different solutions, but only worked for me with this:
http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64
I notice that i didn't use nodist to control the node version like this tutorial, I use NVM and worked fine, i don't test this tutorial with nodist. I used node 5.2.0.

npm install jsdom error on windows?

I have installed nodejs on my windows pc. And it was working fine. But when I tried to install jsdom using
"npm install jsdom" I was prompoted by this error.
node "C:\Program
Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js"
rebuild info it
worked if it ends with ok
ERR! Error: Python does not seem to be installed
at failNoPython (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:78:14)
at Object.oncomplete (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:66:11)
ERR! not ok
npm WARN optional dependency failed, continuing contextify#0.1.2
jsdom#0.2.13 ./node_modules/jsdom
+-- cssom#0.2.3 +-- htmlparser#1.7.5
Can anyone help me regarding this problem?
I had the same issue on Windows 7 (x64 Ultimate), after hours of search and trials, here is how I resolved it. Please follow the steps in the same exact order:
Install Visual Studio 2010/2012 C++ (Express or higher)
Install Windows SDK 7.1
Install "Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1"
Install GTK (C:\GTK)
Install Python (C:\Python27)
Install node.js (x86)
Add [node.js] to path (C:\Program Files (x86)\nodejs\;)
Add [python] to path (C:\Python27\;)
Add [GTK] to path (C:\GTK\bin;)
Add [WindowsSDKDir] System Variable pointing to "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin"
Run "Windows SDK 7.1 Command Prompt" as Administrator
Set environment to x86 using "setenv /x86"
Change directory to "C:\Program Files (x86)\nodejs\"
Run "npm install -g npm"
Run "npm update -g npm"
Run "npm install -g node-gyp"
Run "node-gyp configure build"
Run "npm install jsdom"
Run "npm install ajax"
Run "npm install http-server"
Run "npm install jquery"
Run "npm install xmlhttprequest"
Run "npm update"
I hope this helps.
There is a nice guide to getting JSDom working on Windows here: http://www.steveworkman.com/node-js/2012/installing-jsdom-on-windows/
jsdom has a dependency on contextify, which only recently supports windows. You'll need python and a C++ compiler to install it.
You may also need to do the following
npm install -g node-gyp
node-gyp configure
For windows 8 64-bit, installing zmq and protobuf, the following worked for me:
First, Install Visual Studio 2012
Then, on the command prompt (in your project directory):
SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf
npm install jsdom
jsdom uses contextify for running JavaScript on the DOM. And contextify requires native C++ compiler. According to the official readme, on Windows platform, one has to install:
A recent copy of the x86 version of Node.js for Windows, not the x64 version. (should be okay by default)
A copy of Visual C++ 2010 Express. (or any newer version)
A copy of Python 2.7, installed in the default location of C:\Python27.
If you have python installed already, you would need to add the python install directory to the PATH environment variable.
Assuming that python.exe is in the C:\Python32\ directory, on the DOS prompt you need to type:
set PATH=%PATH%;C:\Python32\;
and then:
node-gyp configure
should work fine without that error.
After almost a half year of solving this issue, reading all forums related to this, I finally found the solution.
What I did was simple in my case because I don't use many apps on this computer.
My Windows 8.1 had many programs installed which confused the NodeJS probably (Frameworks, VS addons, etc.).
So I simply did this:
Removed all programs from MS, that I installed once.
Uninstalled Nodejs
For sure I cleaned the registry with CCleaner
Removed Python, Node-gyp and other apps related to Node.js
Then I reinstalled Node.js with optimism for JSdom which installed correctly, but crashed while running my project. So I searched for the new error which - again - has a simple solution. I had to install an older version of JSdom.
npm install jsdom#4.2.0
Finally, everything works. Hope that helps anyone with this issue.

Resources