简体   繁体   中英

Node.js Angualr template - cannot find msbuild.exe

I've bought a template from a theme website in Angular and I'm attempting to install it using npm install - but no matter what I try I'm running into the same error.

npm ERR! gyp verb found first Solution file build/binding.sln
npm ERR! gyp verb could not find "msbuild.exe" in PATH - finding location in registry
npm ERR! gyp info spawn C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\spike\Downloads\themeforest-VD5sqgks-flat-able-angular-4-admin-template\Template\skeleton\node_modules\node-gyp\lib\build.js:262:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\spike\\Downloads\\themeforest-VD5sqgks-flat-able-angular-4-admin-template\\Template\\skeleton\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\spike\Downloads\themeforest-VD5sqgks-flat-able-angular-4-admin-template\Template\skeleton\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\spike\AppData\Local\npm-cache\_logs\2022-07-31T15_31_41_537Z-debug.log

I've searched around SO and found the following question: Node-gyp cannot find msbuild.exe - however nothing in this post fixed the error, I've tried all of these with no joy and I just can't get it to run.

I use .NET regularly and have Visual Studio installed so I don't know if it's a version conflict or something? If so I really don't know how to resolve it, just thought it might be worth mentioning.

Instructions that came with the template just said to run npm install with no further pre-requisites etc. and I'm really keen not be stuck with a template I can't run. It looks like other people have had success running it so it's definitely a problem relating to my machine. Just can't pinpoint what that is?

I've since added the .NET framework to the PATH but still the same error: 小路

The error logging says

could not find "msbuild.exe" in PATH - finding location in registry

The value C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe is then found in the registry. I'm guessing that C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe doesn't exist and is a left-over from an old installation. (Third party tools like node-gyp shouldn't be using the registry to locate MSBuild. That's a separate issue.)

On Windows the 'Developer Command Prompt for VS 2022' (which can be run from Start -> Visual Studio 2022 -> Developer Command Prompt for VS 2022) will run the 'VsDevCmd.bat' which will add to the PATH.

If you open a 'Developer Command Prompt' and run your npm install command, I expect that MSBuild will be found in the PATH.

If you test that, is the original error message resolved? Does the install succeed or do you get a new and different error message?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM