Node-sass: How to install with VS2015? (Dependency on MSbuild tools 2.0, but have 4.0)

Created on 7 Aug 2015  路  10Comments  路  Source: sass/node-sass

In the node-sass readme it says:

Compiling versions 0.9.4 and above on Windows machines requires Visual Studio 2013 WD.

I have VS2015 installed and not VS2013 and this error is thrown on install:
MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "14.0", "4.0".
Based on my interpretation, node-sass requires MSBUILD tools version 2.0 and I only have 4.0 installed.

Is there a workaround to install node-sass without installing VS2013?

External - NPM OS - Windows npm build

Most helpful comment

Can you try if npm install node-sass --msvs_version=2015 works? Worst case just modify project files by hand :)

All 10 comments

Can you try if npm install node-sass --msvs_version=2015 works? Worst case just modify project files by hand :)

Tried that command, it still didn't work. I'm assuing the format of the version changed for 2015 and the scripts can't parse it.

File "C:\Users\mattm\AppData\Roaming\npm\node_modules\node-sass\node_modules\pangyp\gyp\pylib\gyp\generator\msvs.py", line 1867, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Users\mattm\AppData\Roaming\npm\node_modules\node-sass\node_modules\pangyp\gyp\pylib\gyp\MSVSVersion.py", line 402, in SelectVisualStudioVersion
    versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)

Any tips on which files would I have to modify?

What version of node-gyp is installed? It looks like support for 2015 didn't appear till at least 2.0 https://github.com/TooTallNate/node-gyp/commit/b768d20f387f3518ead9bce93b1d981007d124b8

Oops, forgot this was using pangyp, which is on an older copy of gyp https://github.com/rvagg/pangyp/tree/master/gyp

I'm not sure how to check. I did npm -g ls and searched for pangyp but I don't see it.

The error says it's using pangyp here:

Building: C:\Program Files\iojs\node.exe node_modules\pangyp\bin\node-gyp rebuild --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.
MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "12.0", "14.0", "4.0".

I check the verbose logs from the failed install and it says:
12683 info preinstall [email protected]

Is there an easier to way to check?

pangyp does not know 2015, yet.

You can either:

1) Manually invoke node-gyp instead of pangyp (you need node-gyp configure followed by node-gyp build)
2) Patch https://github.com/rvagg/pangyp/blob/master/gyp/pylib/gyp/MSVSVersion.py to understand 2015 as in https://github.com/TooTallNate/node-gyp/blob/master/gyp/pylib/gyp/MSVSVersion.py#L228-L236
3) Manually edit Visual Studio project files and change the version number. Very probable it will just work.

None of those is truly kosher but this should be easy to solve via one of the above ways.

+1

Here is a general solution for node-gyp with Windows and it麓s Build Tools. It helped me, and now I get no more errors when rebuilding modules.
I removed Visual Studio Express 2015 and used the instructions found at https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

node-sass already depends on node-gyp instead of pangyp. So this issue was actually resolved by https://github.com/sass/node-sass/commit/35aa6dd63152c42956242dd6588d6f796bbc1243.
Sometimes on Windows 8/10, either msbuild in PATH or which node-gyp infers is not the latest one (note that you may have multiple versions of msbuild installed, one with VS and one with some version of .NET Framework and so on). To fix this problem, prepend the value of Environment Variables > Path with latest msbuild.

image

Thanks @am11. Your Windows expertise is always appreciated.

@mattmazzola @Mirodil if @am11's solution doesn't work please update this issue and we'll reopen it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NathanKleekamp picture NathanKleekamp  路  4Comments

amarbham picture amarbham  路  3Comments

paulcpederson picture paulcpederson  路  3Comments

Pixelatex picture Pixelatex  路  3Comments

YepFury picture YepFury  路  4Comments