12

I'm getting the following error when I run my Jenkins job. I've installed MSBuild 15 and 17 and specified the correct path.

Can anyone shed some light on this? Where the issue is. Thanks.

(x86)\Jenkins\workspace\POS4> npm install
> pos4@1.0.10 install C:\Program Files (x86)\Jenkins\workspace\POS4
> node-gyp rebuild


C:\Program Files (x86)\Jenkins\workspace\POS4>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Warning: Missing input files:
C:\Program Files (x86)\Jenkins\workspace\POS4\build\..\build\Release\binding.node
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\Jenkins\workspace\POS4\build\binding.vcxproj(20,3): 

**error MSB4019: The imported project "C:\Micr
osoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file
 exists on disk.**

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:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
gyp ERR! System Windows_NT 10.0.17134
RobC
  • 22,977
  • 20
  • 73
  • 80
EdwardKenway
  • 161
  • 1
  • 1
  • 9

6 Answers6

14

Make sure you're not working with Node 12 as node-gyp then will fail. Version 11.15.0 is the latest working version.

cslove
  • 151
  • 1
  • 2
  • 4
    Why is this downvoted? This is the correct answer to the problem and immediately fixed it. – jmcgriz Oct 07 '19 at 18:57
  • This solved my problem as well. I was getting the following: `gyp ERR! build error gyp ERR! stack Error: \`C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe\` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\\Projects\\quotes.webui\\node_modules\\node-gyp\\lib\\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:223:5) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) gyp ERR! System Windows_NT 10.0.17763` – ShortM Feb 19 '20 at 06:45
  • 3
    And what about versions 14+? So it won´t work for future Node versions? – dawn Apr 05 '21 at 20:33
9

This is quite a common issue faced by users who build on a Windows based operating system. A node-gyp error means that a native module has failed to build. IMHO there has never been one single answer that has directly solved this issue in my experience. However below is a checklist I would suggest to follow if anyone else comes across node-gyp errors. You may have already tried these but just leaving it for reference.

  • Install windows build tools using npm install --global windows-build-tools. This will enable compiling of native node modules and is courtesy of felixrieseberg/windows-build-tools. Build tools include items like Python and Visual C++ packages (Python 2.7 seems to be the preferred one by node-gyp)
  • Configure node-gyp to generate the appropriate build files for your project using node-gyp configure or node-gyp configure --msvs_version=2015 in your case since you mentioned that you have installed a MSBuild 15 and 17. It would be better to stick to one and configure node-gyp to it (Go through node-gyp for more available commands such as rebuild)
  • Ensure your npm config path for Python is set correctly. If you installed the build tools manually or using the link mentioned above ensure that your npm config points to a valid installation directory

    These are just for reference and if I come across any more I will add them here as juggling node-gyp on Windows machines is something I have had trouble in the past and currently.

This error is also commonly thrown for errors caused by native node modules such as SQLite since native bindings are unable to be found.

imaadhrizni
  • 428
  • 4
  • 11
6

Try to downgrade your Node version to 11.15.0, because it is the latest working version.

Check this answer by @aircraft that states the following:

You can use n for node's version management. There is a simple intro for n.

$ npm install -g n
$ n 6.10.3

this is very easy to use.

then you can show your node version:

$ node -v
$ v8.11.1
RobC
  • 22,977
  • 20
  • 73
  • 80
Hany Moh.
  • 949
  • 1
  • 11
  • 11
6

This solved for me when I downgrade the node from 13 to ver 11 with latest npm and VS.

Oreng
  • 61
  • 1
  • 1
1

I got this in windows env too. However, in linux it is fine. So I just copied the node_moduels from linux to windows.

Feng Zhang
  • 1,698
  • 1
  • 17
  • 20
1

I just wanna chip in here as I just happened to resolve this. Make sure to downgrade your node.js to a recommended version of node. I was on current and that was causing issues.