haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.02k stars 662 forks source link

MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "12.0", "14.0", "4.0". [SOLVED] #1721

Closed wzup closed 7 years ago

wzup commented 7 years ago

system info

node: v6.3.1 Windows 10 Pro x64-based npm: 3.10.3

Expected behavior

Haraka installs globally.

Observed behavior

$ npm i -g Haraka
C:\Users\user\AppData\Roaming\npm\spf -> C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\bin\spf
C:\Users\user\AppData\Roaming\npm\haraka -> C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\bin\haraka
C:\Users\user\AppData\Roaming\npm\haraka_grep -> C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\bin\haraka_grep
C:\Users\user\AppData\Roaming\npm\dkimverify -> C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\bin\dkimverify

> dtrace-provider@0.8.0 install C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\node_modules\bunyan\node_modules\dtrace-provider
> node scripts/install.js

> dtrace-provider@0.7.1 install C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\node_modules\dtrace-provider
> node scripts/install.js

> iconv@2.2.1 install C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\node_modules\iconv
> node-gyp rebuild

C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\node_modules\iconv>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
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".
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\user\AppData\Roaming\npm\node_modules\Haraka\node_modules\iconv
gyp ERR! node -v v6.3.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
C:\Users\user\AppData\Roaming\npm
`-- (empty)

npm WARN optional Skipping failed optional dependency /Haraka/modern-syslog:
npm WARN notsup Not compatible with your operating system or architecture: modern-syslog@1.1.4
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "-g" "Haraka"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! iconv@2.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the iconv@2.2.1 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the iconv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs iconv
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls iconv
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\user\app\npm-debug.log
npm ERR! code 1

Steps to reproduce

$ npm i -g Haraka
smfreegard commented 7 years ago

http://stackoverflow.com/questions/14278417/cannot-install-node-modules-that-require-compilation-on-windows-7-x64-vs2012/22411007#22411007

wzup commented 7 years ago

@smfreegard

Nope, it doesn't help. Do you have any other advice?

wzup commented 7 years ago

@smfreegard

Actual I have a question. All the answers in that SO question imply that the user has or has to install MS Visual Studio. This flag implies Visual Studio installed, doesn't it?

--msvs_version=2012

My question is. Can we install Haraka without installing VS? MS offers all build tools as standalone downloads https://www.microsoft.com/en-in/download/details.aspx?id=48159. Aren't they all the same tools used in VS? How may I install Haraka having all MSBuild tools installed?

smfreegard commented 7 years ago

It doesn't imply VisualStudio, just the build tools as you have found in your link. I suspect if you install the 2015 build tools, you'll need --msvs_version=2015 instead.

I've never used Haraka on Windows (thankfully), so others might know a better answer to this then me.

baudehlo commented 7 years ago

Maybe try running: npm install --global --production windows-build-tools

On Wed, Nov 16, 2016 at 8:53 AM, Steve Freegard notifications@github.com wrote:

It doesn't imply VisualStudio, just the build tools as you have found in your link. I suspect if you install the 2015 build tools, you'll need --msvs_version=2015 instead.

I've never used Haraka on Windows (thankfully), so others might know a better answer to this then me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/haraka/Haraka/issues/1721#issuecomment-260951802, or mute the thread https://github.com/notifications/unsubscribe-auth/AAobY35KzZPZdzAcS3WS1ru1N8P07Yilks5q-wrsgaJpZM4Kzuf2 .

wzup commented 7 years ago

I eventually succeeded to install Haraka.

First off, I don't have any ms visual studio installed. And didn't want to install it. I have installed two MS Build Tools. But just installing them doesn't solve the issue.

BuildTools_Full_2013.exe
BuildTools_Full_2015.exe

I had Python 2.7, had it in my PATH, but it doesn't solve the issue either.

This is what I did to solve the issue. From here https://github.com/nodejs/node-gyp

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

The installation process took long time, about 25 mins. It created a directory in my home/ dir: ~/.windows-build-tools/ and populated it with a lot of files (see screenshot below). It also installed its own Python 2.7 in that directory. In spite of I already have Python 2.7 installed. It set its Python as a variable in global npm config file C:\Users\user\AppData\Roaming\npm\etc\npmrc

python=C:\Users\user\.windows-build-tools\python27\python.exe

I also had this settings in my local .npmrc. But I'm not sure if it was set by windows-build-tools. I think I set them by myself manually while trying out different approaches. Delete or set them if anything. C:\Users\user\.npmrc

python=python2.7
msvs_version=2015

It also created Microsoft.Cpp/ directory in C:\Program Files (x86)\MSBuild\. Before there was no such directory there: c__program files x86 _msbuild 2016-11-17 14 42 00

Then I ran the command and Haraka was installed all right at last.

$ npm i -g Haraka

As you can see from the scroll bar it is only half of the files that windows-build-tools installation created. windows-build-tools 2016-11-17 14 08 45

None of those answers and advises were helpful, didn't work for me. Probably, they'll be helpful for others. http://stackoverflow.com/a/22411007/1114926 http://stackoverflow.com/a/16854333/1114926 http://stackoverflow.com/a/21421759/1114926 https://github.com/kin9puppy/vcbuildFixForNode https://github.com/nodejs/node-gyp/issues/972 and many more out there

Just useful links. They shed light on the matter: https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md https://github.com/nodejs/node-gyp/issues/629 https://github.com/felixrieseberg/windows-build-tools

smfreegard commented 7 years ago

Thanks for the follow-up wzup; I'll put some Windows instructions in the README later.