Search code examples
pythonnode.jsv8newrelicnode-gyp

failed to build native modules on after node 16 upgrade and MacOS upgrade


I’ve upgrade to MacOS Monterey (12.3.1) and Node 16. Since then I’m failed running installation on some node modules due to @newrelic/native-metrics with the following error:

Error running install script for optional dependency: "/Users/zivl/github/data-science-client/serverless/ml-platform-services/node_modules/@newrelic/native-metrics: Command failed.
Exit code: 1
Command: node ./lib/pre-build.js install native_metrics

when digging in the logs, I’ve found it is using node-gyp and python so I thought maybe due to upgrading I will need to re-install them - so I did so. but reinstalling node-gyp / python (inc. switching multiple python versions (3.7, 3.9, 3.10) - still didn’t help.

I checked the node-gyp logs and saw the following:

node-pre-gyp http 404 https://github.com/hyj1991/v8-profiler-node8/releases/download/v6.3.0/profiler-v6.3.0-node-v93-darwin-x64.tar.gz

node-pre-gyp WARN Tried to download(404): https://github.com/hyj1991/v8-profiler-node8/releases/download/v6.3.0/profiler-v6.3.0-node-v93-darwin-x64.tar.gz

node-pre-gyp WARN Pre-built binaries not found for v8-profiler-node8@6.3.0 and node@16.14.2 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
...
Failed to execute native-metrics install: No pre-built artifacts to download for your OS/architecture.

the v8-profiler-node8 has no version for node 16. I’ve trying looking for it online and so far didn’t find any solution :(


Solution

  • Eventually, what helped me solve the issue is doing one of the following:

    • install manually a global package of node-gyp and you should set the node to run that version only (read more about it online, I’ll try to find links but it is anywhere on the net).

    • switch to yarn 3 and pnpm and with those package managers the 3rd party scripts are not installed by default as in npm

    • you can always use npm install --ignore-scripts but it sucks to have this flag everywhere…

    • have two versions of python, python2 and python3 in pypenv global

    I hoped this somehow helped you, other answers and solutions are more than welcome :)