Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-gyp rebuild fails in macOS Catalina (10.15) - No rule to make target node_modules/node-gyp/addon.gypi, needed by `Makefile'. #1779

Closed
MattIPv4 opened this issue Jun 16, 2019 · 62 comments
Labels

Comments

@MattIPv4
Copy link
Member

  • Node Version: 10.10.0 / 6.4.1
  • Platform: Darwin Matts-MBP-3.local 19.0.0 Darwin Kernel Version 19.0.0: Fri May 24 17:36:10 PDT 2019; root:xnu-6041.0.0.111.5~1/RELEASE_X86_64 x86_64
  • Compiler: Apple clang version 11.0.0 (clang-1100.0.20.17) Target: x86_64-apple-darwin19.0.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  • Module: Failure occurred during better-sqlite3@5.4.0 install as part of electron-builder
Verbose output (from npm or node-gyp):
> electron-builder install-app-deps --arch x64

  • electron-builder version=20.26.1
  • rebuilding native production dependencies platform=darwin arch=x64
Error: /usr/local/Cellar/node/10.10.0/bin/node exited with code 1
Output:

> better-sqlite3@5.4.0 install /Users/mattcowley/WebstormProjects/MagicCap/node_modules/better-sqlite3
> node-gyp rebuild


Error output:
make: *** No rule to make target `../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', needed by `Makefile'.  Stop.
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/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:240:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/Cellar/node/10.10.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mattcowley/WebstormProjects/MagicCap/node_modules/better-sqlite3
gyp ERR! node -v v10.10.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! better-sqlite3@5.4.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the better-sqlite3@5.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mattcowley/.npm/_logs/2019-06-16T10_20_00_103Z-debug.log

    at ChildProcess.childProcess.once.code (/Users/mattcowley/WebstormProjects/MagicCap/node_modules/builder-util/src/util.ts:255:14)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Socket.stream.socket.on (internal/child_process.js:381:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:606:12)
From previous event:
    at rebuild (/Users/mattcowley/WebstormProjects/MagicCap/node_modules/app-builder-lib/out/util/yarn.js:238:18)
    at /Users/mattcowley/WebstormProjects/MagicCap/node_modules/app-builder-lib/src/util/yarn.ts:20:11
From previous event:
    at installOrRebuild (/Users/mattcowley/WebstormProjects/MagicCap/node_modules/app-builder-lib/out/util/yarn.js:68:17)
    at /Users/mattcowley/WebstormProjects/MagicCap/node_modules/electron-builder/src/cli/install-app-deps.ts:56:9
    at Generator.next (<anonymous>)
    at runCallback (timers.js:694:18)
    at tryOnImmediate (timers.js:665:5)
    at processImmediate (timers.js:647:5)
From previous event:
    at installAppDeps (/Users/mattcowley/WebstormProjects/MagicCap/node_modules/electron-builder/out/cli/install-app-deps.js:174:17)
    at then (/Users/mattcowley/WebstormProjects/MagicCap/node_modules/electron-builder/src/cli/cli.ts:42:48)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! magiccap@1.1.0-b4 postinstall: `electron-builder install-app-deps --arch x64`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the magiccap@1.1.0-b4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mattcowley/.npm/_logs/2019-06-16T10_20_00_173Z-debug.log

2019-06-16T10_20_00_103Z-debug.log

2019-06-16T10_20_00_173Z-debug.log

@MattIPv4
Copy link
Member Author

Hello, so I updated my global installation of node-gyp and it is now failing with a very similar error when it goes to install integer@2.1.0, prior to reaching electron-builder...

Verbose output (from npm or node-gyp):
> integer@2.1.0 install /Users/mattcowley/WebstormProjects/MagicCap/node_modules/integer
> node-gyp rebuild

make: *** No rule to make target `../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', needed by `Makefile'.  Stop.
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/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:240:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/Cellar/node/10.10.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mattcowley/WebstormProjects/MagicCap/node_modules/integer
gyp ERR! node -v v10.10.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! integer@2.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the integer@2.1.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mattcowley/.npm/_logs/2019-06-16T10_33_53_751Z-debug.log

2019-06-16T10_33_53_751Z-debug.log

@MattIPv4
Copy link
Member Author

@MattIPv4
Copy link
Member Author

MattIPv4 commented Jun 16, 2019

Same issue occurs if node-gyp is forced to 5.0.0 in the package by doing npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"

@MattIPv4 MattIPv4 changed the title No rule to make target node_modules/node-gyp/addon.gypi, needed by `Makefile'. node-gyp rebuild fails in macOS Catalina (10.15) - No rule to make target node_modules/node-gyp/addon.gypi, needed by `Makefile'. Jun 16, 2019
@Boxonical
Copy link

I'm running Mac OS Catalina and encountered this issue. I was installing node-memwatch for my node application.

I've tried reinstalling using installer from the official website & brew install node

The error still popped up. My workaround was installing node using nvm instead. I still do not have an idea what actually causes the issue though.

@martinhe9527
Copy link

martinhe9527 commented Jun 18, 2019

same problem,seems the Catalina problem,andone have idea to solve it?

@rvagg
Copy link
Member

rvagg commented Jun 21, 2019

sorry to do this but I'm going to close this and suggest you take this up with the authors of electron-builder. It looks to me like it's a problem with invocation.

I also don't think we're going to be in a position to provide any support for Catalina until it's actually released, we hardly have the people + bandwidth to deal with supported operating systems. Sorry.

@rvagg rvagg closed this as completed Jun 21, 2019
@MattIPv4
Copy link
Member Author

@rvagg This isn't an issue with electron builder. Simply running npm i integer raises the same failure.

@rvagg rvagg reopened this Jun 22, 2019
@rvagg
Copy link
Member

rvagg commented Jun 22, 2019

I want to restate that support for Catalina is a low priority until it's in (or closer to) GA. But we can certainly collect more data on it. I'm certainly not going to jump onto the Catalina train until GA so it's going to be up to you early adopters that are willing to deal with breakage like this and yak shave your way to fixes.

@Boxonical can you paste some output for your failed node-memwatch? Is it the same make: *** No rule to make target ../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', needed by Makefile'. Stop. error?

The fact that it works from nvm is interesting because you're getting an entirely different pathing structure to the global / npm node_modules directory. Given Apple's propensity to screw with /usr/local I'm wondering if they've done something else funky with that that's messing up relative pathing into there.

So, for anyone that wants to help solve this, try this:

When you get an error output that starts with something like this:

> integer@2.1.0 install /Users/mattcowley/WebstormProjects/MagicCap/node_modules/integer
> node-gyp rebuild

and then yields a failure like this:

make: *** No rule to make target `../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', needed by `Makefile'.  Stop.

cd into that first directory, e.g. /Users/mattcowley/WebstormProjects/MagicCap/node_modules/integer and do an ls ../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi using that second path that fails, and see if it resolves. Also try a realpath on that same path to see what it resolves to as an absolute non-linked path. If you're getting errors or weird results from that, mess around with that relative path a bit and see how you can make it work properly. That won't tell us how to fix it here (exactly) but it might give us a hint for how to approach it.

@Boxonical
Copy link

Boxonical commented Jun 22, 2019

Sorry I'm unable to recreate the issue ever since I use nvm to workaround.

I've tried:

  1. uninstall nvm & node
  2. npm install using homebrew / official installer without nvm, attempting to recreate but node-memwatch installed successfully without errors

Prior to workaround I did encountered the same error
make: *** No rule to make target ../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi, needed by Makefile. Stop.

I'm more convinced this is a node pathing issue instead of package (integer / node-memwatch) issue

@vihanb
Copy link

vihanb commented Jul 4, 2019

Following up to @rvagg I do have the same issue and relative to the node-gyp file calling it (build.js) the addon.gypi file does exist. But the addon.gypi does not exist relative to the module being installed. The /usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi file realpath's to itself

@gpersoon
Copy link

gpersoon commented Jul 9, 2019

I had the same issue and I think it is actually a problem with Catalina:
The processing of .. seams to be wrong; it doesn't show all directories (especially of the root directory):

cd /Users
ls ..
Device	Users

While the actual contents of the root directory is:

ls /
Applications			System				bin				etc				mnt				private				tmp
Library				Users				cores				home				net				sbin				usr
Network				Volumes				dev				installer.failurerequests	opt				sw				var

@vihanb
Copy link

vihanb commented Jul 9, 2019

Might have something to do with / root dir becoming Read-only...

There are some changes to the file system layout in Catalina that includes a RO /. They get around the problem of needing to have some paths writeable by using bidirectional symlinks into a writeable filesystem. You can do this in APFS because disk space isn't statically partitioned, which also explains why several filesystems are the same size.

Looks like /Users is either a symlink or FS-level abstraction. I don't have my laptop rn but might be useful to see if realpath /Users is different and if so that may be what's confusing GYP?

@gpersoon
Copy link

Realpath doesn't give any useful clues

realpath /Users
/Users

However i have found a workaround that solves the problem of node-gyp, by setting the config directories of npm to a different directory that doesn't have the problem, like /opt:

sudo mkdir /opt/node
sudo chown {user}: /opt/node
npm config set devdir /opt/node/npm 
npm config set prefix /opt/node/npm-global
export PATH=~/opt/node/npm-global/bin:$PATH

@markandrewj
Copy link

markandrewj commented Oct 14, 2019

Hello, I am being affected by this on macOS Catalina 10.15 GA. Reading the comments makes me suspect, like others, that Apples new security polices (https://support.apple.com/en-ca/HT210650) are the cause of the issue. Currently I manage node through brew. It would make sense that NVM would work properly, if this change was the cause of the issue. I am currently using Xcode 11.1, and I have the terminal tools installed.

...

Small update, I was able to get things working after installing node through NVM. However I still got an error until I removed the old modules in the project I am working on, and then reinstalled fresh copies. Which makes me unsure if NVM fixed the issue, or removing the old packages and lock fixed the issue. I thought I would write an update in case anyone else has problems after upgrading though.

@jonbondani
Copy link

@markandrewj, would you mind to describe all the steps you made to fix the issue? after upgrading some packages and node, my app is no longer working since it's unable to be compiled by node-gyp rebuild.

Thanks

@markandrewj
Copy link

markandrewj commented Oct 23, 2019

Hey @jonbondani, before doing any of the following steps I outline, make sure you have updated xcode, and opened xcode, so it can install the most recent compiler tools. If you haven't done this node-gyp won't be able to compile correctly. For me though, even after I installed the latest version of xcode, I still had the same issue. The issue happens because parts of / are now read only in Catalina, which has been causing issues for node-gyp. According to the issue referenced in this thread though, the issue should be fixed now.

In the end, this is what worked for me:

  1. Using brew, uninstalled node and yarn.
  2. Installed NVM [https://github.com/nvm-sh/nvm].
  3. Installed a version of Node through NVM, and configured it to be my global default.
  4. Reinstalled yarn
  5. Removed the 'node_modules' directory for my project, and then ran 'yarn install' to pull in everything I needed again from my package.json

As a note, one benefit you get from switching to NVM is the ability to add a .nvmrc to your project, which locks it to a specific node version.

@cclauss cclauss added the macOS label Oct 23, 2019
@cclauss
Copy link
Contributor

cclauss commented Oct 23, 2019

make sure you have updated Xcode, and opened Xcode, so it can install the most recent compiler tools

There are TWO ways to do this:

  1. Install all of Xcode (7.6 GB of download and disk space) --or--
  2. Xcode-select Command Line Tools (This is what homebrew uses.) See Is this an Issue with MACOS catalina? #1927

Both work but both have their idiosyncrasies.

@markandrewj
Copy link

markandrewj commented Oct 23, 2019

@cclauss I tied both of the methods you listed, before switching to NVM, without success.

@jonbondani
Copy link

@markandrewj, I've reinstalled xcode comandtools, use nvm to install latest LTS node and followed all the steps that you suggested, but always the same result:

yarn install
yarn install v1.19.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[-/7] ⡀ waiting...
[-/7] ⡀ waiting...
[-/7] ⡀ waiting...
[4/7] ⡀ weak-napi
error /Users/****/node_modules/weak-napi: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/****/node_modules/weak-napi
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@5.0.5
gyp info using node@12.13.0 | darwin | x64
gyp info find Python using Python version 2.7.10 found at "/usr/bin/python"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args   '/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/node_modules/weak-napi/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/Library/Caches/node-gyp/12.13.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/****/Library/Caches/node-gyp/12.13.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/****/Library/Caches/node-gyp/12.13.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/****/node_modules/weak-napi',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 611, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 30, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 45, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 248, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: cannot use a string pattern on a bytes-like object
make: *** [Release/nothing.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/****/.nvm/versions/node/v12.13.0/bin/node" "/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/****/node_modules/weak-napi

thanks

@markandrewj
Copy link

markandrewj commented Oct 24, 2019

I'm not sure any of the following will help, but they are things you could try.

  1. brew update, brew upgrade, brew cleanup, brew doctor
  2. Make sure you are on xcode 11.1 (i.e. run 'xcodebuild -version')
  3. Make sure that you are in fact using the node provided by nvm and not a residual version of node (i.e. run 'which node' to confirm it is the expected path, run 'npm --version' and confirm that it is the expected version). I just noticed in your output that the command is pointing at the nvm path, so this is probably fine.
  4. When I reinstalled yarn, I did not do it through brew. I used 'npm i -g yarn'. This is not recommended by the yarn team, since it makes npm a dependency of yarn. I did this because I didn't want to install using brew, and I didn't want files scattered across my system by building from source.
  5. Make sure to remove the 'node_modules' directory, and package lock file for your project, then yarn install, if you didn't already.
  6. Try using using the LTS version of node.
  7. Try rebooting.

If none of this helps, you will probably find further information by looking for results for the given error.

TypeError: cannot use a string pattern on a bytes-like object

@cclauss
Copy link
Contributor

cclauss commented Oct 24, 2019

@jonbondani wrote:

I've reinstalled xcode comandtools

This is not all of Xcode so my bet is that xcodebuild -version only returned a message about xcode-select. If this is the case, and if Jon wishes to avoid installing all of Xcode then run the commands at #1927 (comment) until com.apple.pkg.CLTools_Executables appears.

TypeError: cannot use a string pattern on a bytes-like object is Python 3 complaining about an incomplete port. Python 2 made no distinction between bytes and str but Python 3 strictly enforces that distinction. A quick fix would be use Python 2 for the install.

@jonbondani
Copy link

@markandrewj
I've tried all your suggestions and still nothing :(

@cclauss , on the first try:

/usr/sbin/pkgutil --packages | grep CL
com.apple.pkg.CLTools_Executables
com.apple.pkg.CLTools_SDK_macOSSDK
com.apple.pkg.CLTools_SDK_macOS1013
com.apple.pkg.CLTools_SDK_macOS1015
com.apple.pkg.CLTools_SDK_macOS1014
com.apple.pkg.CLTools_macOS_SDK

TypeError: cannot use a string pattern on a bytes-like object is Python 3 complaining about an incomplete port. Python 2 made no distinction between bytes and str but Python 3 strictly enforces that distinction. A quick fix would be use Python 2 for the install.

Tried using Python 2.7 (as suggested) with the same result:

yarn install
yarn install v1.19.1
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[-/7] ⠠ waiting...
[-/7] ⠠ waiting...
[-/7] ⠠ waiting...
[4/7] ⠠ weak-napi
error /Users/****/node_modules/weak-napi: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/****/node_modules/weak-napi
Output:
gyp info it worked if it ends with ok
gyp info using **node-gyp@5.0.5**
gyp info using **node@12.13.0 | darwin | x64**
gyp info find Python using **Python version 2.7.10** found at "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python"
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/node_modules/weak-napi/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/****/Library/Caches/node-gyp/12.13.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/****/Library/Caches/node-gyp/12.13.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/****/Library/Caches/node-gyp/12.13.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/****/node_modules/weak-napi',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/src/nothing.o
  LIBTOOL-STATIC Release/nothing.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 611, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 30, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 45, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 248, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: cannot use a string pattern on a bytes-like object
make: *** [Release/nothing.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/****/.nvm/versions/node/v12.13.0/bin/node" "/Users/****/.nvm/versions/node/v12.13.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/****/node_modules/weak-napi

I'm starting to despair, I've been stuck for two days without being able to move forward
Thanks for your help

@amcinerneynewf
Copy link

amcinerneynewf commented Jan 13, 2020

I tried everything in this thread as well as the documentation posted by @cclauss but my issue was the my git repo local directory had a space in it "git repos". After removing the space I was able to install correctly. It appears that gyp doesn't handle spaces in git repository names very well.

the error I was seeing: as you can see the directory starts with 'repos' and not 'git repos':

clang: error: no such file or directory: 'repos/outlook-web-addin/node_modules/node-addon-api'
make: *** [Release/obj.target/weakref/src/weakref.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:194: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 Darwin 19.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/amcinerney/Documents/git repos/outlook-web-addin/node_modules/weak-napi
gyp ERR! node -v v12.14.1
gyp ERR! node-gyp -v v6.1.0
gyp ERR! not ok 

@BigCatGit
Copy link

如果将软件包中的node-gyp强制为5.0.0,则会发生相同的问题 npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"

解决我的问题,谢谢

@xzel23
Copy link

xzel23 commented Feb 13, 2020

In case it helps someone: I still got the error although Xcode was installed on my machine. It works after executing `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer.

@edwin-nel
Copy link

https://docs.npmjs.com/misc/config#unsafe-perm

sudo npm i --unsafe-perm=true

@GreenRidingHood
Copy link

I know I have Mojave, but maybe that can help someone, i spent 2 day for gyp error

In my case I downgraded node 13 to 11 .. and worked

React Native Environment Info:
Binaries:
Node: 11.10.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: ^0.59.10 => 0.59.10
npmGlobalPackages:
react-native-cli: 2.0.1

@theigor
Copy link

theigor commented Mar 22, 2020

Not sure why @cclauss got all the 👎 - I've been having node-gyp issued on Catalina on and off and finally went through his MD and cleared it all out using the acid test and the third (manual) install option. Thanks! Also +1 to @rrrix who found the solution that worked for me.

@Carniatto
Copy link

@theigor cuz does not work for everybody, in my case the acid tests pass but I still got the issue

@cclauss
Copy link
Contributor

cclauss commented Mar 24, 2020

It would be really cool if someone from Apple could jump in and document a permanent solution.

@dsomel21
Copy link

I did a full uninstall and reinstall of yarn, node, nvm and deleted my node_modules and still gave me the giant, unreadable node-gyp rebuild mess.

Downgrading the Node version with NVM helped. (I went from 12.16.1 to 8.17.0.) Kind of unfortunate, because it used to work with 13.3.0 but we'll just have to hacking our way until Apple can figure their mess out.

@platform-kit
Copy link

I solved the issue on my 16" MBP (clean Catalina install) by opening XCode, manually selecting the CLI install directory from the locations tab in preferences, then downgrading to node V11 using NVM.

@pachkovska
Copy link

Upon opening Xcode I noticed the location for the Command Line Tools were empty. (Preferences > Locations). After selecting the tools there, I could run the install.
Thank you so much @hphoeksma. your solution solved my problem.

@i36lib
Copy link

i36lib commented Apr 19, 2020

Same issue occurs if node-gyp is forced to 5.0.0 in the package by doing npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"

Thanks buddy

@tairosonloa
Copy link

Removing package-lock.json and running npm install worked for me.

That's true for me. I already had the xcode tools installed and didn't know why it was falling. It was a project that a coworker initialized on MS Windows. Running the following worked for me:

rm -rf node_modules package-lock.json
npm i

@bnoordhuis
Copy link
Member

This issue seems to have ran its course. For people coming here through search engines: see https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md

@eranhr
Copy link

eranhr commented May 3, 2020

Spent tens of hours trying to solve it (not successful). So I have decided to dive into JS and Py code for debugging.
under /usr/local/lib/node_modules/node-gyp/lib/configure.js line # 299 i found this:
var nodeLibFile = path.join(nodeDir, !gyp.opts.nodedir ? '<(target_arch)' : '$(Configuration)', release.name + '.lib')
which caused me some problems (not sure if this is the right syntax for template strings in JS...). It resulted the args array (passed to py scripts) to include the following item:

-Dnode_lib_file=/Users/josh/Library/Caches/node-gyp/12.13.1/<(target_arch)/node.lib',

obviously .../<(target_arch)/... is not a valid path (it was supposed to be replaced with gyp.opts - arguments/options from terminal).

I don't understand how it worked for others if there is an internal error in the core lib of node-gyp

@rrrix
Copy link

rrrix commented May 4, 2020

@eranhr You're probably using an old version of node-gyp / node-pre-gyp.

Make sure your dependencies/resolutions are using a recent version.

I use yarn and always add something like this:

  "resolutions": {
    "node-gyp": "^6.1.0",
    "node-pre-gyp": "^0.14.0"
  }

If you're using npm instead of yarn, you can use npm-force-resolutions to use the same kind of forced dependency resolution behavior as yarn.

One of the major benefits and major pitfalls of JS ecosystem is version pinning - however that sometimes results in old packages that don't ever get upgraded to use new versions of critical packages such as this.

@Weavingtempest
Copy link

This worked for me.
I noticed that xcodebuild was not available on the command line. I ended up needing too enable command line tools Under Xcode > Preferences > Locations

See the following,
https://stackoverflow.com/questions/24445229/why-is-xcodebuild-command-not-found-in-this-build-script

@braco
Copy link

braco commented Jul 8, 2020

I fixed this by upgrading sharp in package.json. It's worth going through any packages that might be requiring node-gyp and making sure they're up to date.

@khanhdevvn
Copy link

Removing package-lock.json and running npm install worked for me.

That's true for me. I already had the xcode tools installed and didn't know why it was falling. It was a project that a coworker initialized on MS Windows. Running the following worked for me:

rm -rf node_modules package-lock.json
npm i

Thank bro,
I have fixed my issue with this suggest

@tduboisalbizzati
Copy link

tduboisalbizzati commented Mar 10, 2021

Try to add a package-lock.json from a teammate. It can be possible that some modules need specific versions of some others...
Also I had to do a npm install winston-syslog before npm install. This resolved the problem for me in node 14.15.1.

@currentcreative
Copy link

currentcreative commented Mar 22, 2021

I found this elsewhere and I have no idea what it does, but I deleted package-lock.js and package.js files and then ran this:

npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"

And for some reason, that seems to have worked. When I tried to clone the same repo in a new directory and install it again, it was broken again with the same errors. Maybe I need to run that line of code every single time (??) but I'm afraid to do it again and break that one repo I got working in the first directory.

EDIT: someone helped me by pointing out node-sass causes a lot of node-gyp errors. To fix it, I just had to install node-sass independently first before running 'node install' because it has tight native bindings to the version of Node you're using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests