282

I'm trying to use the

npm install steam

but I am getting an error saying

error

I'm not sure how to fix this and I have gotten this on two different npm module installs. I can install other modules however.

What I have tried: Install whatever dependencies it needs. (ursa, node-gyp etc) Install Visual C++ 2005. Install Visual C++ 2010. Change the enviroment variable path to /VC/ (found on another StackOverflow thread/question. Googled, googled & googled.

I also get an error trying do:

npm install ursa

The error is:

error2

5
  • Did you install it with the x64 compiler as well? The error message is hinting about ursaNative.vcxproj wanting to build for x64 but that it is an invalid platform. Feb 9, 2014 at 12:33
  • @Karl-JohanSjögren, When I tried install an x64 bit version of Visual C++ 2010 I get: Please resolve the following: A newer version of Microsoft Visual C++ 2010 Redistributable has been detected on the machine.
    – prk
    Feb 9, 2014 at 13:05
  • Don't know anything about that error I'm afraid. But the initial problem I would think is because you don't have the x64 compiler installed. Feb 9, 2014 at 13:09
  • I solved this problem !!! please use the stable version of Node
    – THB
    Aug 30, 2017 at 7:13

18 Answers 18

679

Try this from cmd line as Administrator

optional part, if you need to use a proxy:

set HTTP_PROXY=http://login:password@your-proxy-host:your-proxy-port
set HTTPS_PROXY=http://login:password@your-proxy-host:your-proxy-port

run this:

npm install -g --production windows-build-tools

No need for Visual Studio. This has what you need.

References:

https://www.npmjs.com/package/windows-build-tools
https://github.com/felixrieseberg/windows-build-tools

28
  • 9
    Worked for me on Windows 10 64bit. Thank you!! :)
    – XSYS
    Dec 8, 2016 at 8:06
  • 4
    worked for me as well on Windows 10 64bit, the other above did not, thanks !
    – lauWM
    Dec 15, 2016 at 16:05
  • 4
    Only this solution seems to work on Windows 10 64 bit. Thanks!
    – hemu
    Jun 13, 2017 at 10:54
  • 30
    I found that this doesn't work because node-gyp forces version v140 and the installer above puts down the latest version (currently VS2017 which is v150). I had to add --vs2015 to the install line to get it to put down the right version. I figured this out from a variety of sources, but in particular npk48's comments really helped. This is the command that worked for me: npm install --global --production windows-build-tools --vs2015 After this I was successful at installing better-sqlite3 where I wasn't before.
    – james
    Sep 27, 2018 at 3:37
  • 4
    Thanks for this answer. Worked on W7 64 bits
    – GTPV
    Dec 6, 2018 at 22:51
37

I know it's a very old question, but is the first in my google search and after some time I got how to solve this.

find node on your windows with:
as @janaka-bandara suggested you can use the native
where node
if you don't have it for some reason you can install which with node
$ npm install -g which
$ which node
after cd into the directory, inside the directory cd into node_modules\npm folder and finally:
$ npm install node-gyp@latest
here worked, the answer is from this site

10
  • 17
    how about npm install -g node-gyp@latest
    – Xianlin
    May 22, 2015 at 8:33
  • windows stuff, if you are running unix-based so is okay, but since npm is installed on "Program Files" folder on windows thing become a bit harder, I think. (old answer, can't reproduce this now to be sure)
    – Edu Ruiz
    May 22, 2015 at 19:47
  • 9
    didn't help me :-(
    – Simon H
    Apr 9, 2016 at 8:38
  • 1
    Hi Edu, i followed the same steps and it still shows the error while running npm install, I am using windows 8.1 Apr 25, 2016 at 12:55
  • 5
    when i fired npm install node-gyp@latest it worked . But after that when i fired - npm install heapdump it gives same error
    – AJS
    Nov 22, 2016 at 7:37
19

It's mentioned in the Documentation clearly as below: https://github.com/nodejs/node-gyp#installation

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).

npm install --global --production windows-build-tools 
2
  • 2
    As mentioned in some other comments this installation takes quite long but it works
    – velval
    Mar 27, 2019 at 6:31
  • 3
    as someone mentioned in another comment, adding --vs2015 on the end of this command is worth trying if it doesn't work by itself. It was the only solution on this thread that worked for me: npm install --global --production windows-build-tools --vs2015
    – HaulinOats
    Jul 24, 2019 at 13:53
14

Look at the installation instructions for node-gyp - you can't just npm install node-gyp. I see you've installed Visual C++, but there's more to it.

What version of windows do you have? If I knew that I might be able to tell you which part of the node-gyp instructions you didn't do, but check them out and you should be able to figure it out. I've gone through a bit of pain for this stuff too.

2
  • Hello, I checked there and I installed the required things but it's still not working. (sorry for a super-late reply!)
    – prk
    Sep 27, 2014 at 18:02
  • If I were you, I'd re-do the installation steps as written. There may be some intricacy that makes simply having the components installed insufficient. But I don't know anything about ursa if its an ursa specific issue.
    – B T
    Sep 29, 2014 at 4:24
12

I tried the above suggested npm install --global --production windows-build-tools but found that the installation was always hanging forever.

I managed to fix the problem by installing Node.js 8 instead of Node.js 10.

1
  • 2
    INstallation has taken 90minutes for me so perhaps it was still doing something on your pc
    – CharybdeBE
    Dec 20, 2018 at 9:14
8

Just to add to the above answer, anyone finding an issue of the installers taking forever, I found my issue was python, I uninstalled both my versions 3 and versions 2.

The re-ran the command in PowerShell terminal as the admin and it installed almost straight away.

npm install --global --production windows-build-tools 
1
  • 2
    I second this. Uninstalling Python 2.7 fixes this issue with the windows-build-tools.
    – Matthew
    May 24, 2018 at 19:39
8

PLEASE FOLLOW THE FLOW CORRECTLY WINDOWS 10x64

  1. Powershell run as administrator
  2. npm install -g node-gyp
  3. npm install --global --production windows-build-tools
5

For me worked install the component "VCBuild.exe", just dowload the wizard, install and them open the cmd again as administrator and try run again. Updated link to dowload the wizard here

2
  • Didn't try this actually, but seems like the most straightforward and to-the-point solution! Jan 22, 2021 at 3:15
  • Worked for me. Just install Microsoft Build Tools 2015 from the link. Aug 23, 2021 at 19:15
4

Faced this issue while trying to install a VueJs project. The solution that worked for me was to replace the deprecated package "node-sass" with "sass".

Replaced

"node-sass": "^4.5.3",

with

 "sass": "",
1

Tried npm install mongoose --msvs_version=2012, if you have multiple Visual installed, it worked for me

1
  • bear in mind that this will help you only if you have Visual studio 2012 installed
    – Capaj
    May 26, 2015 at 12:01
1

The problems here are to do with the npm node-gyp module

I found the solutions offered on the build page for that project effective.

node-gyp page on github

There's a fully automatic way and a manual way.

2
  • Thanks! This worked for me. On Windows 10, after the automatic installation, I had to manually run npm config set msvs_version 2015 and then npm config set python %USERPROFILE%\.windows-build-tools\python27\python.exe. After that I was able to build sleep Jun 7, 2017 at 12:33
  • Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24210 : Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel.
    – Green
    Oct 22, 2017 at 3:01
1

As Matt said (https://stackoverflow.com/a/43323045/2767413) you should install the build-tools for windows. However, I did it via cmd and got an error, although I am the administrator -

Please restart this script from an administrative PowerShell!
The build tools cannot be installed without administrative rights.
To fix, right-click on PowerShell and run "as Administrator".

I got the same error via a PowerShell.

For windows 7, the administrative PowerShell can be found under:

Control Panel -> System and Security -> Administrative Tools -> Windows PowerShell Modules

1

I tried running the following commands but the PowerShell instance ends up hanging/freezing:

npm install -g node-gyp
npm install --global --production windows-build-tools 

Therefore, instead of running the app on Windows I transferred over the application to a Ubuntu VM instance and was able to run npm install with no issues.

So if none of the above solutions work and if you don't mind working in a Linux environment, then try creating a Linux VM and porting over your codebase onto it. Then run npm install and see if it works.

0

I managed to get it working by following Option 2 on the Windows installation instructions on the following page: https://github.com/nodejs/node-gyp.

I had to close the current command line interface and reopen it after doing the installation on another one logged in as Administrator.

0

For those the above answer does not work, here is another possible solution to look at.

Issue: On installing npm os-service package i was getting below error error MSB4019: The imported project "d:\M icrosoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct

Even the installation of build tools or VS 2015 did not work for me. So I tried installing below directly via PowerShell (as admin)

https://chocolatey.org/packages/visualcpp-build-tools/14.0.25420.1 Command: choco install visualcpp-build-tools --version 14.0.25420.1

Once this was installed, set an environment variable VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140

Then installation of the package worked perfectly fine after these.

0

i know this is old, i actually just had the same issue. i was able to solve it by running npm install -g node-gyp and fixed! npm

0
-1

npm install --global windows-build-tools

just run this command via powershell (right click and run as administrator!)

worked for me..

-5

1)install "lite server" and then try below command :
npm run lite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.