Installing --global windows-build-tools never completes - node.js

I am trying to install --global windows-build-tools by running below command
npm install --global windows-build-tools -verbose
No matter if I try through PowerShell or CMD (both as Administrator), the installation gets stuck in the same step.
npm info run windows-build-tools#5.2.2 postinstall node_modules/windows-build-tools node ./dist/index.js
[##################] | reify:resolve: info run windows-build-tools#5.2.2 postinstall node_modules/windows-build-tools node ./dist/index.js
Is there a reason why this might not complete?

According to the windows-build-tools repo
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).
recommended approach:
Go to node-download-page
Download LTS version for windows
Follow the installation instructions
When you got to this window, check the checkbox
After the installation it will prompt you to this window, it will automatically download the necessary dependencies
If you want to use this package(not recommended):
You should try to roll back to version 4.0.0
Run the command-line as administrator and try this:
npm install --global windows-build-tools#4.0.0
related question

If you're having trouble installing windows-build-tools (which I had a problem with recently), you should roll back to version 4.0.0.
Run PowerShell as Administrator, and then type in the following command (assuming you have node and npm installed).
npm install --global windows-build-tools#4.0.0
This process can take some time, so please be patient.
Built-in Node.js Build Tools
There are built-in Node.js build tools, so it is recommended to use this. In fact, if you go on the npm or GitHub page of the windows-build-tools package, it will say that you should use the Node.js build tools.
To do this, go to the official Node.js download website, and download the LTS version. Then, run the installer. At a point in the installation, it will have a checkbox that says Automatically install the recommended tools. Make sure to check that!
When you install it, it will also install Chocolatey, and install the build tools like the windows-build-tools package.
Even though both of these work, it is recommended to use the Node.js built tools!

Following this thread for a while now.
Disclaimer: Please note that I know this is not directly answering your question about why the process gets stuck but I want to share my solution anyway.
The installation via chocolatey did not work for me, as mentioned in:
https://github.com/felixrieseberg/windows-build-tools/issues/245
https://github.com/felixrieseberg/windows-build-tools/issues/152
Then, I found this microsoft page. On this page, the person asked this question:
I tried to install the Microsoft Visual C++ Build tools. The installer
(filename is visualcppbuildtools_full.exe) stops right after the start
of the installation it says a setup package is missing or damaged("Ein
Setuppaket fehlt oder ist beschÃĪdigt"). The option to download it
again doesnt work. Downloading the installer again doesnt help. Trying
to do an offline installation doesnt work either and I get the same
error. How can I find out what exactly the problem is and how can I
solve it?
The solution mentions the page https://my.visualstudio.com/Download that provides different build tool versions:
I was able to download and install "Build Tools for Visual Studio 2017 (version 15.9)".

Related

Unable to build native packages for node

So Im running an Electron app that has some native modules of one them being a package called better-sqlite3. I run yarn and yarn is able to install all packages without a problem but when it gets to the building steps, everything breaks.
I get a bunch of diffrent node-gyp error outputs of which 2 I have been able to save so I can show here here is the important part of the error output for the first error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\bepop\Documents\DeveloperData\Clippy\app\node_modules\better-sqlite3\build\deps\action_before_build.vcxproj]
Full error
In terms of this error I've tried doing multiple things such as installing microsoft visual build tools in many diffrent ways such as manually going to their website and downloading the IDE, I've also tried installing the build tools through NPM with:
npm install --global --production windows-build-tools
It always succesfully installs the build tools but still it errors out on me, I've also tried editing the npm config with:npm config set msvs_version 2017
still doesnt work. I have also tried going to the installation of the Visual Studio and manually checking: "VC++ 2017 version 15.7 v14.14 latest v141 tools"
Also nothing.
I do remember at some point I was able to get everything to build normally with Windows 10 and I never had a problem but not anymore. I've been trying to fix this issue by myself for months now and I've just been sticking on working on the project on my macbook where it never has issues building the better-sqlite3 package.
1 more thing I have tried is completely wiping my computer from everything and starting fresh because at some point i had changed so many things that I lost track of what I had installed and what I did not.
If I remove the better-sqlite3 package from the package.json file everything runs smoothly and I am able to run my project normally but I need the better-sqlite3 package. I could use another package but I really shouldnt have to do that, I'd like to get to the bottom of why this i snot building.
Edit:
Updated: I added Microsoft build tools v14.0.23107.0 to my pats variable and now it outputs error:
C:\Users\bepop\Documents\DeveloperData\Clippy\node_modules\integer\build\integer.vcxproj(21,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Fixed the issue for myself:
Delete node modules folder
Open PowerShell with admin privileges and run in order
npm install --global --production --vs2015 --add-python-to-path windows-build-tools
npm install --global --production --add-python-to-path windows-build-tools node-gyp
Go to ~/.npmrc and make sure these are your settings:
msvs_version=2015
python=python2.7
First remove all the visual studio version installed from your system , and also remove the entries from path and system variable .
and follow the below URL
https://github.com/nodejs/node-gyp#readme
Every thing run fine after removing of better-sqlite3 this package entry from package.json because other packages don't have any native dependency . and this better-sqlite3 is native module after downloading, this module get build using tool node-gpy that will need two things installed on your system i.e. python and visual studio .
So try to follow the above URL steps.
it will definitely work.

Npm error cannot find module

While running npm command I get the error
Error: Cannot find module 'C:\Windows\System32\node_modules\npm\bin\npm-cli.js'.
I tried uninstalling and installing nodejs but with no luck. Also I tried configuring the env vars
I'm not entirely sure about this, but I dont remember having nodejs/npm installed in Windows directory. It should be in your Appdata somewhere. Your install Paths maybe somehow corrupted
But here is a possible solution:
Go here:
Install it and run the following commands:
nvm list
nvm install [version]
for example:
nvm install v10.15.3
The Command should automatically select the installed version as default.
For further information check their Github Readme.
If they don't work right off, be sure to restart the Version Manager OR be sure to follow the instructions led out by the Github Readme.
Version Manager have one big benefit: The Community keeps them updated and because they use different Path architectures they can be installed at places where they weren't originally meant to be from the original installer which lead to a whole different outcome for you because they probably will not install directly into System32.
Other Node Version Manager you could check out (should all be Windows):
https://github.com/hakobera/nvmw
https://github.com/nullivex/nodist
Hope it helps!

Unable to install node.js package 'scrypt' using npm on windows

Installing scrypt using npm on windows is giving following error.
The build is failing due to node-gyp
From github documentation node-Gyp is listed as pre-requisite as it is required to build scrypt. Make it sure to install node-Gyp
using npm install -g node-gyp
For successfull working of this plugin you will also need to 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).
for other options and alternatives follow node-gyp documentation
Before installing scrypt
Follow installation instructions given at github
For NodeJS 10.5.0 and higher
My answer could be a little bit out of topic, but I encountered a similar error with the installation of the scrypt library for NodeJS v12: during the compilation of the C/C++ modules with node-gyp a lot of compiling warnings and errors appear.
Though, there is an elegant solution.
Since version 10.5.0 NodeJS has a crypto.scrypt(...) function, which (with several other functions from crypto module) could cover almost all real use-cases.
So, a decent solution could sound like: Remove scrypt-package from your code and use the appropriate functions from the crypto-native module.
Sadly, but in most cases it is not the best solution for a real business
first you need to install windows-build-tools
run this command first
> npm install --global --production windows-build-tools

Not being able to run bower in VS 2012

Since yesterday I have been trying to install and use bower for managing my dependencies. After going through many articles although I have been able to install it. I am not being able to run it. Beside many articles I also followed this video:
Bower running in Package Manager Console in Visual Studio install
As the video is in some other languages even though I followed all the commonds, I could not get
$env:path
After doing everything when I type bower in the Package manager console, it gives me error
Thanks in advance for helping me out.
PS: I have already installed npm and node.
In order to use Bower correctly in Windows, you need to install msysgit correctly. This is the requirement as specified in bower github https://github.com/bower/bower#a-note-for-windows-users.
The option you have to select during installation is Run Git from the Windows Command Prompt.
After successful installation. Restart Visual Studio and then you are good to go.
In my case, after installing msysgit, I installed bower using:
PM> Install-Package Bower
Above step automatically installed dependencies (node.js, jquery)
I also had to specify relative path to bower.cmd:
PM>.\MyProject.bin\bower.cmd install semantic-ui

NPM - Can't install socket.IO

I am trying to install socket.io on windows with npm for use on a nodeJS server.
First, when I typed "npm install socket.IO" i had an error in the log saying something about python and node-gyp. I installed python 2.7.3 and set the environment variables.
Now I got a new error, which has something to do with visual studio (what the hell does VS have to do with npm ? Is it about the compiler? ).
The error is the same as here npm install for some packages (sqlite3, socket.io) fail with error MSB8020 on Windows 7
But when I use the option in the answer instead of the error it tells me something about a possible data loss (c4267) but doesn't log any error.
Then when I start my app, it tells me cannot find module socket.io still
What could this come from ?
Oh and also when i do npm config get root it tells me "undefined" could it have anything to do with it ?
Should I install the modules globally or locally ?
At least one of the packages in Socket.IO's dependency tree is a C/C++ addons which needs to be compiled on your system as it's installed. And, since it's a dependency, if it doesn't succeed in installing, neither will Socket.IO.
To enable cross-system compilation, Node.js uses node-gyp as its build system. You'll need to have it installed as a global package:
npm install -g node-gyp
As well as have its dependencies installed. Abridged version:
Python 2
C/C++ Compiler / Build Tools
For Windows, Microsoft Visual Studio 2013 (C++ or Windows Desktop) (Express edition)
For 64-bit, may need Windows 7 64-bit SDK
Then, you should be able to install Socket.IO as a local package so you can require it:
npm install socket.io
I had a similar problem on Mac.
What resolved my problem is installing a slightly older version of Socket.io.
I did:
npm install socket.io#"~0.8.1"
which would install the latest version between 0.8.0 to 0.8.9, but not 0.9.0 or above.
Socket.io then installed perfectly.
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 gyp via an environment variable so you can avoid having to set the --msvs_version=2012 property.
Examples:
set GYP_MSVS_VERSION=2012 for Visual Studio 2012
set GYP_MSVS_VERSION=2013e (the 'e' stands for '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
The problem causing the compile failure is that the ws module installed by the engine.io module required by socket.io pulls in a backlevel version of nan. See https://github.com/BrowserSync/grunt-browser-sync/issues/95 for details. To work around the problem after the build failure:
cd to node_modules/socket.io/node_modules/engine.io/node_modules/ws
edit package.json to change the release of nan from 1.4.x to 1.6.0
issue command node-gyp rebuild
You should now be able to use socket.io
Another approach is to use Docker for Windows and spin up a NodeJS environment. While developing you can mount your Node code as a Docker volume and so continue to update your code from Windows but execute it and install it's dependencies inside a Linux VM. When you deploy you might prefer to use a Dockerfile that COPY's your Node code into your Docker image and so bakes it into the release image you deploy.
This approach might be required if you don't want to risk changing the socket.io version of your code or its dependencies.
It also may be a valuable solution if you planned to deploy to a corporate Intranet or public/private Cloud.
Docker can also be very handy for testing deployment under different versions of Node without disturbing the development environment of your Windows computer (e.g. for testing a NodeJS lib).
Official NodeJS Docker images
An explanation of how to use these images
this problem makes me very troubled..
I tried many solutions.
I installed .NET Framework 2.0 SDK.
I installed Python 2.7.x
I installed VS 2012 Express
I set some paths
I executed npm install xxx with the argument --msvs_version=2010(or 2012/2013..)...
But all failed.
finally, I uninstalled Python & .NET Framework 2.0 SDK & VS 2012, clear those paths,enable Windows Update, install all essential updates, restart my computer
then execute commands below:
npm install node-gyp -g
npm install socket.io -g
npm install browser-sync -g
there is no errors in installation logs.
Note : this solution may not work for you, but for me

Resources