Can´t install Canvas (npm) on Windows - node.js

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)

Related

node gyp says build tools are undefined

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

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

npm install on mingw

Introduction
I want to install aglio with npm on Windows:
npm install -g aglio
It fails when node-gyp rebuild, complaining MSB3428.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
The error message instructs me to install Visual Studio.
Question
Can I install aglio (or any other packages involving node-gyp) without installing VisualStudio?
(My computer has scarce storage.)
Preferably, I want to make use of MinGW.
(Configuring GYP_GENERATOR would solve the problem?)

Problems running the ripple emulator on Visual Studio 2013

I am trying to run the ripple emulator on Visual Studio, however I cannot seem to get pass the cannot find module './lib/plugin'error as follows:
C:\Users[user name]\Documents\Visual Studio 2013\Projects\Cordova\Cordova>call "C:\Program Files (x86)\nodejs\"\nodevars.bat
Your environment has been set up for using Node.js 0.10.33 (ia32) and npm.
------ Ensuring correct global installation of package from source package directory: E:\PROGRAM FILES (X86)\VISUAL STUDIO\COMMON7\IDE\EXTENSIONS\FUBXMEK2.O2B\packages\vs-mda
1>MDAVSCLI : error : Cannot find module './lib/plugin'
PS: The previous error I got was cannot find module 'q' however this was resolved by running npm install from CLI.
I am trying to create a Cordova application using Visual Studio. Any ideas how I can resolve the above error?
It seems something went wrong while installing vs-mda, you can try following to re-install:
Close Visual Studio
Open cmd
npm install -g [path to vs-mda example C:\Users[user-name]\AppData\Roaming\npm\node_modules\vs-mda]
npm install -g [path to vs-mda-targets example C:\Users[user-name]\AppData\Roaming\npm\node_modules\vs-mda-targets]
OR
Go to Tools --> Options --> Tools for Apache Cordova --> Cordova Tools --> Clear Cordova Cache
For the second method above (Clear Cordova Data) try running visual studio as administrator if it fails the first time around.

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