node-sha3: npm install sha3 fails - node10/npm6
Traceback:
sha3@1.2.0 install /Users/noahzinsmeister/Documents/github/smart-contracts/snowflake_poc/node_modules/sha3 node-gyp rebuild
CXX(target) Release/obj.target/sha3/src/addon.o
…/src/addon.cpp:59:36: error: no matching member function for call to ‘NewInstance’
info.GetReturnValue().Set(cons->NewInstance(argc, argv));
~~~~
/Users/noahzinsmeister/.node-gyp/10.0.0/include/node/v8.h:3851:44: note: candidate function not viable: requires single argument ‘context’, but 2 arguments were provided
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
^
/Users/noahzinsmeister/.node-gyp/10.0.0/include/node/v8.h:3848:44: note: candidate function not viable: requires 3 arguments, but 2 were provided
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
^
1 error generated.
make: *** [Release/obj.target/sha3/src/addon.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/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:225:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command “/usr/local/Cellar/node/10.0.0/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /Users/noahzinsmeister/Documents/github/smart-contracts/snowflake_poc/node_modules/sha3
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 17
- Comments: 27
Commits related to this issue
- Pin sha3 to 1.2.3 in attempt to fix node-gyp build failures https://github.com/phusion/node-sha3/issues/32 If this does not work, we may have to investigate upgrading to Web3 Beta55 sooner than we e... — committed to ShipChain/engine by mlclay 5 years ago
- Fix npm sha3 issue by using sha3 2.0.2 Resolves to updated version of sha3 that doesn't break See https://github.com/phusion/node-sha3/pull/33 and https://github.com/phusion/node-sha3/issues/32#issu... — committed to oskarth/semaphore by oskarth 5 years ago
- Fix npm sha3 issue by using sha3 2.0.2 Resolves to updated version of sha3 that doesn't break See https://github.com/phusion/node-sha3/pull/33 and https://github.com/phusion/node-sha3/issues/32#issu... — committed to oskarth/semaphore by oskarth 5 years ago
@bladexxv Since this issue doesn’t manifest until Node.js 10.x, a workaround would be to downgrade to Node.js 9.11.1 (the previous non-LTS release) or 8.11.1 (the current LTS release).
The minimum path to fixing this issue altogether in Node.js 10.x would be:
sha3package to npm would need to publish the new patch version to npm.I followed @canterberry steps, but it didn’t work in my case unfortunately. I was forced to downgrade node to 11.13.0
Steps I followed to downgrade from node 12 to 11:
sudo npm install -g ninstall a program called nsudo n 11.13.0downgrading node to 11.13.0rm -fR node_modulescleaning dependenciesnpm installreinstall dependenciesBTW - I am on mac
Yeah, the problem is that
node-gypis not compatible with Node.js 12.x, which means the 1.x branch of this project (and any other project that uses native C compilation steps) is incompatible with Node.js 12.x. Unfortunately, older versions of web3 still depend on this old implementation.As a workaround, you can try
npm install sha3@2.0.2in your project, which may coerce web3 to resolve its sha3 dependency to this new version. Version 1.x and 2.x of this package are interface-compatible, so there should be no compatibility issues with web3 in doing so.Hi @canterberry , first of all thanks for taking the time to help with this issue. Please find below the info requested:
In trying to reproduce this locally (i.e: installing web3 from scratch in an empty project using Node.js 12.1.0 via a simple
npm install web3), I get annode-gyp rebuilderror on the scrypt@6.0.3 package. That package hasn’t been updated in 3 years, so even if you were able to get the sha3 package resolved to 2.x, that version of web3 would still have a hard dependency on an scrypt package with no version available that works on Node.js 12.x.The steps you followed look correct, but I tried following them, myself, and saw this warning in the console:
Apparently both
npmandyarnenforce fuzzy version selectors even when attempting to force a resolution viaresolutions.There doesn’t appear to be a workaround, then, for using web3 on Node.js 12.x. The only solution may be to submit a PR to web3 that migrates its dependencies to alternatives (or newer versions) which do not depend on the
node-gyptoolchain.@canterberry any ETA on the port? I might have some time to help out this weekend. Also, will we even be able to merge the PR? The repo hasn’t been updated in ages, I don’t know if anyone who has push access is still around.
@canterberry please find my answers below
😄 Thanks! Dealing with the Rube Goldberg of the npm dependency graph can be rough, so thanks for your patience. I’m confident that I’ve done what I can, within the scope of this package, for compatibility with all (known) environments. The rest depends on maintainers of the individual packages. web3@1.0.0-beta.35 is unlikely to ever work in Node.js 12.x because of its dependency on scrypt, which appears to have been abandoned for several years. Since then, web3 seems to have removed its dependency on this package (sha3), and has made scrypt an optional dependency (?) so that its inevitable build failure on Node.js 12.x no longer causes the web3 install itself to fail.
Hi @canterberry . Sorry I only went back now to check again. You are the real MVP for taking all this time helping and fixing this. So bad news: it still wont work with web3@1.0.0-beta.35 - do you know why? GOOD NEWS: it does indeed work now with latest web3 (beta.55). Thanks so much!
@bytezantium v1.2.3 has been released. Please give that a shot (via the same steps outline above). Since
1.2.3should match the fuzzy version selector^1.1.0, the forced resolution should work.Ah, I was hoping it was that easy. Apparently not!
Have a look at the
npm-force-resolutionslibrary, or consider using Yarn which natively supports selective version resolutions. Looks like with either of these methods, it’s almost as easy to force a resolution as my initial suggestion.(TIL how to force transitive dependency resolutions in npm and yarn.)
TL;DR:
Run
rm -fR node_modulesto clear out your project’s resolved dependencies.Run
npx npm-force-resolutionsto patch your package-lock.json.Run
npm installagain.