npm install jsdom error on windows? - node.js

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.

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

How must a development environment be set up to build prestashop theme assets?

I'm trying to build the Prestashop classic theme's assets, according to Prestashop's documentation. I'm on Windows 10, using cygwin. Here is what I did in detail:
I forked the latest stable tag (1.7.6.7).
I ran ./tools/assets/build.sh in cygwin. (I also tried in Windows Terminal and step by step, i.e. cd theme dir, followed by npm install.)
npm install threw an error complaining about missing Python.
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
I installed Python 3 and got an error complaining about missing Python 2.7
I installed Python 2.7 and got an error complaining about missing Visual Studio 2008.
Projet "E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln" sur le noud 1 (cibles par défaut).
ValidateSolutionConfiguration:
Génération de la configuration de solution "Release|x64".
MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft
Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.
[E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln]
Génération du projet "E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln"
terminée (cibles par défaut) -- ÉCHEC.
Before I continue on a trial and error basis, I'd like to ask if someone knows what prerequisites are needed to set up a complete development environment for Prestashop themes. Or more precisely, what is the list of software I must install before being able to run npm install?
https://devdocs.prestashop.com/ clearly doesn't give any clue, they only explain installation of npm and composer here.
How to set up a Prestashop development environment?
The answer was not straight forward:
The theme uses node-sass, which is compiled using node-gyp.
As the readme of node-gyp states, on Windows we need to install npm install --global --production windows-build-tools, which takes care of Python and Visual Studio.
The theme of the latest stable release of Prestashop 1.7.6.7 uses a node-sass version (^4.11.0), which is not compatible with node 12.x
Therefore, we need to install nvm for windows and use the latest version of the node 10.x branch.
With these steps, npm install will work.
npm run build will fail, because the npm script is not compatible with Windows.
In stead of npm run build (which calls NODE_ENV=production webpack --progress --colors --debug --display-chunks), we have to run
set NODE_ENV=production
npx webpack --progress --colors --debug --display-chunks
It looks like the Devs of Prestashop never tried to get their work running on Windows.
Classic theme uses webpack to compile assets, more informations:
https://devdocs.prestashop.com/1.7/development/compile-assets/
Best way is to navigate to themes/classic/_dev and run npm install :) later you can use npm run watch or npm run build or any other defined script

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)

Node Sass couldn't find a binding for your current environment

I am having issues building an app because node-sass keeps failing with the error.
ERROR in Missing binding /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node 0.10.x
I have tried running
npm rebuild node-sass
which says
Binary is fine; exiting.
When running node -v I get v6.2.2
Which is different to what the sass error says "Node 0.10.x". I can't figure out why it is getting the wrong version. I have also tried removing the node_modules folder and running npm update or npm install, both of which did not resolve the issue. Any ideas?
I had the same problem
There is an error in your gulpfile:
Error: Missing binding E:\allapp\badshaindiancuisine\node_module\node-sass\vendor\win32-x64-46\binding.node
Node Sass could not find a binding for your current environment:Windows 64-bit with Node.js 4.x
Found bindings for the following environment:
    - OS X 64-bit with Node.js 4.x
How to solve the problem
By going into the project folder and then executing the command:
npm rebuild node-sass
For those that are using Visual Studio:
Currently working for VS 2015, 2017, 2019, 2022 (via below and/or replies from this post)
Task Runner Explorer can't load tasks
For VS 2015
Go to: Tools > Options > Projects and Solutions > External Web Tools
For VS 2017(.3), VS 2019, and VS 2022
Tools > Options > Projects and Solutions > Web Package Management > External Web Tools (per #nothrow)
In VS 2017, 2019, 2022, you also need to put $(PATH) above $(VSINSTALLERDIR)\Web\External
Reorder so that $(PATH) is above $(DevEnvDir)\Extensions\Microsoft\Web Tools\External
Deleting node_modules and running npm install and then npm rebuild node-sass did nothing.
**Just execute: ** npm rebuild node-sass --force
If the above for some reason didn't work out for you, try this:
Delete node-sass folder under node_modules
npm install
In my case it also couldn't find Python.
Following procedure solved the issue (Windows):
npm rebuild node-sass --force
-- cannot find python.exe, if you have Python installed, add it to your path:
set PYTHON=C:\Python27\Python.exe
-- else: download python "Windows x86-64-MSI" installer from https://www.python.org/downloads/release/python-2714/
-- install python
-- at installation start check: add env variable to path
-- after successfull installation:
npm rebuild node-sass --force
-- finished successfully
Worked for me:
Just delete the node-sass folder and run npm install.
I had the same problem in a Windows environment, receiving the following error:
Error: Missing binding C:\Development{ProjectName}\node_modules\node-sass\vendor\win32-ia32-47\binding.node
Node Sass could not find a binding for your current environment: Windows 32-bit with Node.js 5.x
Found bindings for the following environments:
   - Windows 64-bit with Node.js 6.x
None of the npm commands listed in the other answers here (npm install, npm rebuild node-sass, etc.) worked.
Instead, I had to download the missing binding and place it in the appropriate destination folder.
The bindings can be found on git. Match the file with the folder name identified after /node_modules/node-sass/vendor/ in your error message ('darwin-x64-11' in your case, so you'd want the darwin-x64-11_binding.node file).
Create the missing folder in your project (/node_modules/node-sass/vendor/darwin-x64-11), copy the .node file to the new directory, and rename it to binding.node.
Node-sass release URL:
https://github.com/sass/node-sass/releases
I had a similar problem and the reason was that there were two versions of Node installed in my machine: one "global" and another one at the project level.
Sass will build correctly only if the Gulp build is running under Node.js 4.x version, so make sure you upgrade the version of Node you are using.
PS: If you completely remove the node_modules folder in your project and re-build from scratch, npm will download the correct dependencies for your current system & node version.
npm rebuild node-sass --force
Or, if you are using node-sass within a container:
docker exec <container-id> npm rebuild node-sass --force
This error occurs when node-sass does not have the correct binding for the current operating system.
If you use Docker, this error usually happens when you add node_modules directly to the container filesystem in your Dockerfile (or mount them using a Docker volume).
The container architecture is probably different than your current operating system. For example, I installed node-sass on macOS but my container runs Ubuntu.
If you force node-sass to rebuild from within the container, node-sass will download the correct bindings for the container operating system.
See my repro case to learn more.
in some cases you need to uninstall and install node-sass library. Try:
npm uninstall --save node-sass
and
npm install --save node-sass
look at this its work for me,
Stack link here
node-sass node module uses darwin binary file which is dependent on the version of node. This issue occurs when the binary file is not downloaded or wrong binary file is downloaded.
[![Node sass error][1]][1]
Reinstall node modules will download expected binary of node-sass:-
For Mac users:
rm -rf node_modules
npm cache clean --force
npm i
npm rebuild node-sass --force
For Windows users:
rmdir node_modules
npm cache clean --force
npm i
npm rebuild node-sass --force
but for some users, you need to check your node version's compatibility with node-sass version. Make it compatible using below table and run above commands again to fix this issue.
This is node compatibility table with node-sass
NodeJS | Supported node-sass version | Node Module
Node 17 7.0+ 102
Node 16 6.0+ 93
Node 15 5.0+ 88
Node 14 4.14+ 83
Node 13 4.13+, <5.0 79
Node 12 4.12+ 72
Node 11 4.10+, <5.0 67
Node 10 4.9+, <6.0 64
Node 8 4.5.3+, <5.0 57
Node <8 <5.0 <57
If issue is still not fixed, check node-sass supported environment's list:- https://github.com/sass/node-sass/releases/
* Docker related answer here *
Answer for if you are seeing this problem, or something similar, and are using Docker.
Cause: When copying over the current file structure to inside the Docker container, you may be copying over node modules from one OS system to another (e.g. a Mac to Linux container).
Solution:
Add a .dockerignore, and inside add:
node_modules
This will cause an npm install to install the bindings for the docker environment, rather than your local machine environment.
If your terminal/command prompt says:
Node Sass could not find a binding
for your current environment:
OS X 64-bit with Node 0.10.x
and you have tried the following commands such as:
npm cache clean --force
rm -rf node_modules
npm install
npm rebuild node-sass
& still NOTHING works..
Just run this in the terminal manually: node node_modules/node-sass/scripts/install.js
now run npm start or yarn start
Try to add suffix --force
npm rebuild node-sass --force
For my particular case none of the above answers worked. So what it worked:
rm -rf node_modules
rm -rf /tmp/*
rm -rf /root/.npm/node-sass
npm uninstall --save node-sass
npm cache clean --force
npm cache verify to check that nothing is left in the cache
npm install
Altough I haven't tried to reproduce the sequence it was a combination of the above that worked.
In addition you may also try:
npm install --save node-sass or npm install node-sass -g
npm rebuild node-sass
npm install bindings
I had the same problem
throw new Error(errors.missingBinary());
^
Error: Missing binding /path/to/project/node_modules/node-sass/vendor/linux-x64-47/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 5.x
Found bindings for the following environments:
- Linux 64-bit with Node 0.10.x
- Linux 64-bit with Node.js 5.x
That was because I did npm install using a different nodejs version,
try deleting node_modules folder installing and starting
cd your_project
rm -rf node_modules
npm install
npm start or gulp or whatever
If you are using nvm do
nvm use stable // or your favorite version
// remove node_module directory
npm install
npm start or gulp or whatever
I had the same problem with Node v7.4.0 Current (Latest Features).
Did some reading here and downgraded Node to v6.9.4 LTS and after running npm rebuild node-sass it downloaded the binary and everything started working.
Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-48_binding.node
Download complete .] - :
Binary saved to D:\xxx\xxx-xxx\node_modules\node-sass\vendor\win32-x64-48\binding.node
Caching binary to C:\Users\user\AppData\Roaming\npm-cache\node-sass\3.13.1\win32-x64-48_binding.node`
I'm a Windows 8 user, recently updated Node to v8.11.1 and npm to v6.0.0 and faced similar issue. Nothing worked - npm install -g node-sass#latest or deleting the node-sass directory from the project node_modules/ - none of 'em worked for me.
The Laravel Mix was throwing an error to my browser console saying a missing node: win32-x64-57. I don't know whether it's because a slower internet connection or something, the node was missing during the update.
Hence some of the answers directed me to look at the Node-Sass releases, and I found the solution.
Step 1: Check your node-sass version using the command: npm view node-sass version (the {your version} in step 4)
Step 2: Get to Node-Sass Releases
Step 3: Get your release and find the missing node in the assets listed under every release, and download the file
Step 4: Get to your PC's C:\Users\{User}\AppData\Roaming\npm-cache\node-sass\{your version}\ and put the downloaded .node file inside the version folder
And you are done.
In my case the node-sass version was 4.9.0 and the missing node was win32-x64-57_binding.node, so I downloaded the .node file from 4.9.0 release and followed step 4.
For Visual Studio 2015/2017, Right Click on your package.json and Click on Restore Packages.
This will make sure that the npm from the Visual Studio Tools External Tools is run and the binding will be rebuild based on that.
I had the same issue. I couldn't find any proper working solution in here, so I found mine:
Inspired by #Rob-Scott solution and other pointing that we could have 2 versions of Node.js installed, I went to C:\Program Files (x86)\nodejs and realized that I had a node.js version installed in addition to the VS default installation.
My solution was quite simple:
Go to Tools > Options > Projects & solutions > Web package management > External web tools
Click on add an entry (most left of the top-right block of buttons)
Enter C:\Program Files (x86)\nodejs, validate by pressing enter
Bring it at the top of the list
Enjoy
Probably Node.js is not set well in the PATH variable, but this is my working very quick solution, my 2 cents :)
This happens when in your workstation you run an update of Node.js and you are using node-sass globally.
So you should uninstall node-sass globally
npm uninstall -g node-sass
And then you have to install it globally, again
npm install -g node-sass
The post dependencies for node-sass is not getting installed without the package.json inside node-sass
Running it manually solved for me
node node_modules/node-sass/scripts/install.js
credit: link
Run the following commands, it works fine for me.
npm install node-sass -g
npm rebuild node-sass
nvm use 10.16.3
node node_modules/node-sass/scripts/install.js
ng serve --poll=2000
This worked for me:
yarn add --force node-sass#4.14.1 or yarn add --force node-sass
This usually happens because the environment has changed since running npm install.
Running npm rebuild node-sass builds the binding for the current environment.
Create a new directory in node_modules/node-sass/vendor/linux-x64-46/ .
the download fil from https://github.com/sass/node-sass/releases
(linux-x64-59_binding.node) based upon your version.
paste it in node_modules/node-sass/vendor/linux-x64-46/ rename it to binding.node
I had this issue when upgrading from VS 2017 Professional to Enterprise
Close VS
Delete node_modules
Open VS
Right click package.json and select 'restore packages'
Delete node_modules folder.
Install dependencies again. (npm i)
None of the install/rebuild solutions resolved the issue for me (using gulp).
Here is how I resolved it:
1) Download the missing binding file from the repository.
2) Rename the file binding.node.
3) Create node_modules/node-sass/vendor/darwin-x64-11 (path from error message) directory if it doesn't exist.
4) Add the binding file to node_modules/node-sass/vendor/darwin-x64-11
Just refresh your npm cache and:
npm cache clean --force
npm install
It always works for me in the same case.
UPD: Your problem may also be by reason of absence of a global sasslib.
npm install -g sass
Open Visual Studio 2017
Go to Tools -> Options…
Go to Projects and Solutions -> Web Package Management
Move $(PATH) to the top of that list and close that window.
Restart Visual Studio.
This worked in my case, because my node version is 11.x
Probably you have a build with different node version than the current one. Try running these commands and it should fix the issue.
npm cache clean --force &&
rm -rf node_modules &&
rm -rf package-lock.json &&
npm i

pushbots-cli not recognized but installed windows 10

I have no idea where to go with this.
I spent 3 days searching solution for this issue
I installed pushbots-cli (through npm) but i cant get it working.
Getting "'pushbots' is not recognized as an internal or external command,
operable program or batch file."
searched all over the net. Gave up.
Please help if you had such problem.
I can use cordova and phonegap plugin (using command line) but not pushbots itself.
I did settled it on Mac, but not on windows.
(node installed, python, node-gyp as well)
very big thanks in advance.
Follow these steps....this is what I did.
Install python: http://www.python.org/getit/windows/
Install Microsoft Visual Studio C++ 2012 Express version: http://go.microsoft.com/?linkid=9816758
Install node-gyp: npm install -g node-gyp
Then run npm install -g pushbots-cli in the terminal
Type pushbots --help to ensure it is installed
Also make sure node and npm are installed.

Resources