npm install apiconnect fails on macOS Catalina (v10.15.7)

398 views Asked by At

I the Node.js package apiconnect will not install on my new MacBook Pro. The Node.js version is v10.22.1, NPM version 6.14.6, Python 3.8.3

I ran the following command:

sudo npm install -g --unsafe-perm=true --allow-root --loglevel verbose apiconnect

The error that I receive is similar to what I received in the container ([email protected]). The error from the log:

61922 silly install [email protected]
61923 info lifecycle [email protected]~install: [email protected]
61924 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle true
61925 verbose lifecycle [email protected]~install: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/local/lib/node_modules/apiconnect/node_modules/appmetrics/node_modules/.bin:/usr/local/lib/node_modules/apiconnect/node_modules/.bin:/usr/local/lib/node_modules/.bin:/Users/steve/opt/anaconda3/bin:/Users/steve/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
61926 verbose lifecycle [email protected]~install: CWD: /usr/local/lib/node_modules/apiconnect/node_modules/appmetrics
61927 silly lifecycle [email protected]~install: Args: [ '-c', 'node extract_all_binaries.js || node-gyp rebuild' ]
61928 silly lifecycle [email protected]~install: Returned: code: 1  signal: null
61929 info lifecycle [email protected]~install: Failed to exec install script
61930 timing action:install Completed in 26347ms
61931 verbose unlock done using /Users/steve/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
61932 timing stage:rollbackFailedOptional Completed in 8528ms
61933 timing stage:runTopLevelLifecycles Completed in 468567ms
61934 verbose stack Error: [email protected] install: `node extract_all_binaries.js || node-gyp rebuild`
61934 verbose stack Exit status 1
61934 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
61934 verbose stack     at EventEmitter.emit (events.js:198:13)
61934 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
61934 verbose stack     at ChildProcess.emit (events.js:198:13)
61934 verbose stack     at maybeClose (internal/child_process.js:982:16)
61934 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
61935 verbose pkgid [email protected]
61936 verbose cwd /Users/steve
61937 verbose Darwin 19.6.0
61938 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "--unsafe-perm=true" "--allow-root" "--loglevel" "verbose" "apiconnect"
61939 verbose node v10.22.1
61940 verbose npm  v6.14.6
61941 error code ELIFECYCLE
61942 error errno 1
61943 error [email protected] install: `node extract_all_binaries.js || node-gyp rebuild`
61943 error Exit status 1
61944 error Failed at the [email protected] install script.
61944 error This is probably not a problem with npm. There is likely additional logging output above.
61945 verbose exit [ 1, true ]
2

There are 2 answers

0
Steven J. Ponessa On BEST ANSWER

The issue was resolved by changing the order of the directories in my PATH environment variable and running the install as sudo and using the --unsafe-perm=true and --allow-root options.

The full command used for the installation was:

sudo npm install -g --unsafe-perm=true --allow-root --loglevel verbose apiconnect

For the PATH environment variable, the installation of anaconda3 Python/Jupyter Notebook package put their directories at the front of the path. By changing the path to so that:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:...

where the first directories in the path, the installation worked.

1
Stephen Taylor On

Does this work?

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

node-gyp rebuild