Skip to content

node-gyp gets confused by MSBuild on the %PATH% #1653

Closed
@twoi

Description

@twoi
  • Node-gyp Version: v3.8.0
  • Node Version: v11.7.0
  • Npm Version: 6.5.0
  • Platform: Windows 8.1 Enterprise / 6.3.9600 N/A ビルド 9600 / x64-based PC

I tried to build build a simple module on msvs 2017, but that failed as long as an old MSBuild
c:\Program Files (x86)\MSBuild\14.0\Bin\amd64
was on the %PATH%

When I removed the path, node-gyp build built just fine. It also worked, when I added the latest MSBuild to the %PATH%
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64

So node-gyp configure doesn't seem to care if there is an MSBuild.exe on the path, but node-gyp build stumbles upon an insufficient MSBuild on the path, although it does work fine if there is none at all on the path.

As this took me hours to figure out, I would suggest node-gyp build just ignore any MSBuild on the path. (Otherwise, what's the point of node-gyp configure going to great pains to find a suitable MSBuild in the first place?)

Judging from stackoverflow and github issues, i'm not the only one stumbling on this. In fact, several other developers had "success" after uninstalling (!!) their old Visual Studios - I'm assuming what cured it was that the uninstall also fixed their %PATH%.

Verbose output:
C:\Projects\node>node-gyp configure --verbose --target=v0.12.18 --msvs_version=2017
[...]
gyp verb find vs2017 Found installation at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.14393
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.17763
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64
gyp verb find vs2017   - Found Microsoft.VisualStudio.VC.MSBuild.Base
gyp verb find vs2017   - Using this installation with Windows 10 SDK
gyp verb find vs2017 using installation: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise
[...]
gyp info ok

C:\Projects\node>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@11.7.0 | win32 | x64
gyp info spawn msbuild
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
このソリューション内のプロジェクトを 1 度に 1 つずつビルドします。並行ビルドを有効にするには、"/m" スイッチを追加してください。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build us
ing the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and
then selecting "Retarget solution". [C:\Projects\node\build\addon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:188:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Projects\node
gyp ERR! node -v v11.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions