node.jswindowscygwinnpm-installgyp

Getting 'OSError: [Errno 2] No such file or directory:' during `node-gyp` compilation of module in `npm install`


npm install throws error below. One of the modules my application depends on is a native Node.js module, re2 (it depends on node-gyp, which means it is compiled at install time):

 File "/cygdrive/c/Users/<Me>/AppData/Roaming/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py", line 2025, in GenerateOutput
    version=msvs_version)
  File "/cygdrive/c/Users/<Me>/AppData/Roaming/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py", line 213, in __init__
    self.Write()
  File "/cygdrive/c/Users/<Me>/AppData/Roaming/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py", line 340, in Write
    f.close()
  File "/cygdrive/c/Users/<Me>/AppData/Roaming/npm/node_modules/node-gyp/gyp/pylib/gyp/common.py", line 396, in close
    os.unlink(self.tmp_path)
OSError: [Errno 2] No such file or directory: '/cygdrive/c/git/ecom/git-repo-inspector/node_modules/@my-app/some-mod/node_modules/re2/C:\\git\\ecom\\git-repo-inspector\\node_modules\\@my-app\\some-mod\\node_modules\\re2\\build/binding.sln.gyp.7gDS9t.tmp'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (c:\Users\<Me>\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "c:\\Users\\<Me>\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\git\ecom\git-repo-inspector\node_modules\@my-app\some-mod\node_modules\re2
gyp ERR! node -v v11.9.0
gyp ERR! node-gyp -v v4.0.0
gyp ERR! not ok
npm verb lifecycle re2@1.8.4~install: unsafe-perm in lifecycle true
npm verb lifecycle re2@1.8.4~install: PATH: C:\Users\<Me>\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\git\ecom\git-repo-inspector\node_modules\@my-app\some-mod\node_modules\re2\node_modules\.bin;C:\git\ecom\git-repo-inspector\node_modules\@my-app\some-mod\node_modules\.bin;C:\git\ecom\git-repo-inspector\node_modules\.bin;C:\cygwin64\usr\local\bin;C:\cygwin64\bin;C:\Program Files (x86)\Python36-3

My npm is configured with Python 2.7:

python = "c:\\Python27\\python.exe"

npm version:

$ npm -v
6.9.0

node-gyp version:

$ node-gyp --version
v4.0.0

I have installed Visual Studio Profession 2017's Desktop development with C++ as per here.

Update: I found a way to solve it, read the details here


Solution

  • Read the details here of how I was able to solve it, or at least find a work around that suited my needs.

    Update: I contributed a patch to the node-gyp product to address this issue for users on Windows (that may also be using Cygwin)