-1

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: Path

kc9jud
  • 146
  • 1
  • 11
Web Develop Wolf
  • 5,996
  • 12
  • 52
  • 101

1 Answers1

1

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?

Update: The new errors about v120 build tools not found and about Microsoft.Cpp.Default.props not found would appear to indicate that the npm install is trying to use C++ and that the C++ tools have not been installed with Visual Studio.

Launch the Visual Studio installer and add the 'Desktop Development with C++' workload. Note that with VS2022, the C++ tools are at v143.

Jonathan Dodds
  • 2,654
  • 1
  • 10
  • 14
  • Got a new error this time - The build tools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 build tools. – Web Develop Wolf Aug 05 '22 at 21:31
  • When attempting to run the install from VS Code - I get the following error - error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. – Web Develop Wolf Aug 05 '22 at 21:55
  • I added an update to my answer. – Jonathan Dodds Aug 05 '22 at 23:18
  • Ok so ran that - but still getting the same error - I've even tried installing the C++ tools from an earlier version in case it was conflict – Web Develop Wolf Aug 08 '22 at 08:55