Web3.js: npm install error - installing web3 in macOS Mojave

Created on 21 Nov 2018  路  5Comments  路  Source: ChainSafe/web3.js

Hi, I always run to the error when tried npm install web3:

> [email protected] preinstall /Users/chuanqin/Documents/Github/web3js-test/node_modules/scrypt
> node node-scrypt-preinstall.js

Error: Error: Command failed: ./configure
configure: error: in `/Users/chuanqin/Documents/Github/web3js-test/node_modules/scrypt/scrypt/scrypt-1.2.0':
configure: error: C compiler cannot create executables
See `config.log' for more details


> [email protected] install /Users/chuanqin/Documents/Github/web3js-test/node_modules/scrypt
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /usr/local/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:289:12)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack     at Socket.stream.socket.on (internal/child_process.js:381:11)
gyp ERR! stack     at Socket.emit (events.js:182:13)
gyp ERR! stack     at Pipe._handle.close (net.js:606:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/Users/chuanqin/.npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/chuanqin/Documents/Github/web3js-test/node_modules/scrypt
gyp ERR! node -v v10.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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:

However, the weird thing is, if I tried to use sudo npm install web3, this problem will be gone, even this error message does not mention a thing about access...

I searched and it still does not look like an access problem. I have no problem with installing many other packages without using sudo (which I try to avoid per many experts' suggestion). Maybe I am missing something here? Any input is appreciated.

MacOS version: 10.14.1

Most helpful comment

@chuanqin3 - so you reinstalled the entire OS and apps before you got this to work? Are there no better ways to uninstall and reinstall these - npm, node, python 2, python3, etc?

Arun

All 5 comments

Today I took 2 hours to do a fresh reinstall of my macOS and it solved my problem. I hope my solution helps other people.

Just installing Xcode worked as well

Just installing Xcode worked as well

Good point. People who run to my problem can try this first. Unfortunately, it does not work on my side. I believe something is messed up with my sudo and configuration.. so a fresh reinstall is the last resort. :/

@chuanqin3 - so you reinstalled the entire OS and apps before you got this to work? Are there no better ways to uninstall and reinstall these - npm, node, python 2, python3, etc?

Arun

@dragupta No I don't. I believe something deep in my system is broken. Abusive usage of sudo can deteriorate your system quickly.

Was this page helpful?
0 / 5 - 0 ratings