node-sass icon indicating copy to clipboard operation
node-sass copied to clipboard

MSBUILD error

Open rohit1049 opened this issue 9 years ago • 17 comments

I have tried the troubleshooting steps for installing node-sass. But it did not work fine. It did not installed the node-sass and generated the npm.err and npm.log files. The log file is attached. npm_log.txt How can it be solved?

rohit1049 avatar Aug 23 '17 09:08 rohit1049

Long contents


> [email protected] install C:\DCDx\test\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-48_binding.node

> [email protected] postinstall C:\DCDx\test\node_modules\node-sass
> node scripts/build.js

Building: C:\Program Files\nodejs\node.exe C:\DCDx\test\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 8/23/2017 2:31:46 PM.
Project "C:\DCDx\test\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|x64".
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\DCDx\test\node_modules\node-sass\build\binding.sln]
Done Building Project "C:\DCDx\test\node_modules\node-sass\build\binding.sln" (default targets) -- FAILED.

Build FAILED.

"C:\DCDx\test\node_modules\node-sass\build\binding.sln" (default target) (1) ->
(_src_\libsass target) -> 
  MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\DCDx\test\node_modules\node-sass\build\binding.sln]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.53

xzyfer avatar Aug 23 '17 09:08 xzyfer

What npm command did you run?

xzyfer avatar Aug 23 '17 09:08 xzyfer

@xzyfer npm install -ddd node-sass > npm.log 2> npm.err

rohit1049 avatar Aug 23 '17 09:08 rohit1049

Something is wrong with Visual Studio installation, vcbuild is a pretty old thing.

saper avatar Aug 26 '17 09:08 saper

Please follow the refer to the minimum requirements for node-gyp as in our README https://github.com/nodejs/node-gyp#on-windows You should be able to just download our precompiled binaries. If you had an issue with that, that is also covered in our TROUBLESHOOTING guide.

nschonni avatar Aug 27 '17 17:08 nschonni

Install all the required tools and configurations using Microsoft's windows-build-tools by running npm install -g windows-build-tools from an elevated PowerShell (run as Administrator).

It takes a while.

Then run npm config set msvs_version 2015 -g

sorted the issue for me

garhbod avatar Nov 16 '17 04:11 garhbod

@garhbod work like the charm . this line enough npm install -g windows-build-tools . .

rtertret

mohamedebrahim96 avatar Jan 05 '18 12:01 mohamedebrahim96

@garhbod Thanks a lot, that helped

pavelgordon avatar Jan 12 '18 18:01 pavelgordon

@garhbod Man, you just save a life ! Spent many hours and after that I found your fix and worked like a charm ! (y)

hani647 avatar Jan 20 '18 07:01 hani647

@garhbod Worked for me, No need for Visual Studio. This has what you need:

npm install --global --production windows-build-tools

Thanks!

carlosquijano avatar Feb 12 '18 17:02 carlosquijano

I ran into the exact same issue that the original post reported. The fix suggested above by garhbod and confirmed by many others did not work for me. npm install -g windows-build-tools was always hanging.

I finally managed to get it working by downgrading Node.js from the version 10 branch to the version 8 branch.

gsidler avatar Jun 06 '18 07:06 gsidler

@gsidler it was hanging here too (npm version 6.1.0, node version 8.11.2), but as npm install -g windows-build-tools stopped logging (logs to file C:\Users\MyUserName.windows-build-tools\build-tools-log.txt ) I just hit ctrl-c to terminate and after running npm config set msvs_version 2015 -g I could successfully run npm install, which in turn wants to compile (...)\node_modules\node-sass\build\binding.sln

andersand avatar Jun 13 '18 13:06 andersand

Same thing happened to me on same versions as @andersand - his suggestion to run npm config set msvs_version 2015 -g worked. I was able to do npm install after that.

ScubaDrew avatar Jun 16 '18 18:06 ScubaDrew

@garhbod Thanks! It worked.

planck4 avatar Jun 20 '18 17:06 planck4

nice one @garhbod

dwale avatar Jul 06 '18 10:07 dwale

An additional step that might prevent further problems is that you should run the npm install for your project in an elevated PowerShell (I usually just do it from the terminal in VSC - which lacks permissions). Thanks @garhbod.

AaronOliver94 avatar Jul 25 '18 09:07 AaronOliver94

npm install -g windows-build-tools works total fine, but at some cases where there can be restriction on administration permission the below command saves the effort

npm install --unsafe-perm node-sass

girijashankarj avatar Aug 26 '18 19:08 girijashankarj