felixrieseberg / windows-build-tools

:package: Install C++ Build Tools for Windows using npm
MIT License
3.4k stars 237 forks source link

npm install fails when installing VisualStudio 2019 #182

Closed fuyutsuki closed 5 years ago

fuyutsuki commented 5 years ago

Hi, I encountered this problem, so propose some problems and solutions. It would be nice if solution already exists.

Overview

> node-gyp rebuild

D:\Repository\misskey>if not defined npm_config_node_gyp (node "D:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:430:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/next_tick.js:76:17)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\Repository\misskey
gyp ERR! node -v v11.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! misskey@10.98.3 install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the misskey@10.98.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

As this line shows, windows-build-tools recognizes Visual Studio 2019 and is looking for MSBuild.exe.

gyp ERR! stack Error: spawn D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT

Solution

I think that the easiest and most flexible way is to add an option or environment variable so that we can specify the path to MSBuild.exe.

My environment

felixrieseberg commented 5 years ago

Ah, this puts us in a tricky spot. From what I can tell, Node and Visual Studio 2019 don't play nice together just yet (https://github.com/nodejs/node-gyp/issues/1663).

I'm not sure what the best solution is - maybe detect VS2019 and warn?

fuyutsuki commented 5 years ago

@felixrieseberg Ahh, until then it will be decided to give up using the VS2019 as it will be fixed over time.

Thank you!