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

Not usable on Node.js 12 #2070

Open
filips123 opened this issue Jun 2, 2019 · 25 comments · May be fixed by #2730
Open

Not usable on Node.js 12 #2070

filips123 opened this issue Jun 2, 2019 · 25 comments · May be fixed by #2730

Comments

@filips123
Copy link
Contributor

@filips123 filips123 commented Jun 2, 2019

Issue

Truffle and its sub-packages (truffle-contract) are unusable on Node.js 12.

This needs to be fixed quickly because it currently makes any package that uses truffle-contract unusable on Node.js 12.

Details

Node.js 12 removed some deprecated functions from the V8 add-on API which are used by some of Truffle dependencies.

One of that dependencies is sha3@1.2.2 which is used by eth-lib#keccakjs. To fix this, you need to update all dependencies yarn.lock. This should install sha3@1.2.3 which has fixed compatibility with Node.js 12.

Another dependency with problems is scrypt.js@0.2.0 which is used by web3#web3-eth#web3-eth-accounts. It was fixed in scrypt.js@0.3.0. Problem with this is that the fixed version is used only in web3@1.0.0-beta.55 which is incompatible with Truffle (#1690). To fix this, you need to update Truffle to support web3@1.0.0-beta.55 which will use the fixed version of scrypt.js.

Maybe there are also some other broken dependencies.

Logs from CI

Error with sha3:
https://travis-ci.com/filips123/truffle/jobs/204732468

Error with scrypt:
https://travis-ci.com/filips123/EthAvatar.JS/jobs/204728583

Environment

  • Operating system: Ubuntu 14.04 on Travis CI
  • Node.js version: 12.3.1
  • NPM version: 6.9.0
@gnidan

This comment has been minimized.

Copy link
Member

@gnidan gnidan commented Jun 2, 2019

Hey @filips123, thanks for bringing this up. This incompatibility is a known issue but unfortunately it's not something we can "fix quickly".

Firstly, upgrading to Web3.js v1.0.0-beta.55 is not an option, since there are breaking changes that would have to wait until Truffle v6. This upgrade has been something we've been attempting for at least 6 months, without success. I won't say more now, but expect an announcement soon about Web3.js versioning. A number of projects having been working with Web3.js directly and we are in the process of outlining a path forward here.

As for the sha3 issue, we can look into upgrading that; this may be more feasible. Feel free to open a pull request if you have a clear understanding of the work entailed.

Sorry about this. I understand it's frustrating—Node v12 has lots of features that I can't wait to get my hands on! Please bear with us and the rest of the community as we seek to address the limitations preventing this from working (or please help if you can!)

@filips123

This comment has been minimized.

Copy link
Contributor Author

@filips123 filips123 commented Jun 2, 2019

@gnidan I created PR #2071 that upgrade dependencies. This should fix the issue with sha3 but scrypt still needs to be fixed.

@filips123

This comment has been minimized.

Copy link
Contributor Author

@filips123 filips123 commented Jun 2, 2019

And you can also see my Travis CI build with updated dependencies:
https://travis-ci.com/filips123/truffle/jobs/204809466

@hmijail

This comment has been minimized.

Copy link

@hmijail hmijail commented Jun 13, 2019

Given that this is a known problem and looks like it will take some time to fix, it would be very helpful to document the problem in the Truffle installation instructions page.

@dnx2k

This comment has been minimized.

Copy link

@dnx2k dnx2k commented Jun 14, 2019

Another issue regarding Node 12 (reproduction on clean project):

$ truffle init
$ truffle develop

truffle(develop)> test

Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Artifacts written to /tmp/test-119514-22057-6jhhyg.j89hi
> Compiled successfully using:
   - solc: 0.5.8+commit.23d335f2.Emscripten.clang

TypeError [ERR_INVALID_REPL_INPUT] [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL
    at process.<anonymous> (repl.js:224:15)
    at process.emit (events.js:205:15)
    at process.emit (/home/user/.nvm/versions/node/v12.4.0/lib/node_modules/truffle/build/webpack:/~/source-map-support/source-map-support.js:465:1)
    at _addListener (events.js:226:14)
    at process.addListener (events.js:274:10)
    at Runner.run (/home/user/.nvm/versions/node/v12.4.0/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:846:11)
    at Mocha.run (/home/user/.nvm/versions/node/v12.4.0/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:572:17)
    at /home/user/.nvm/versions/node/v12.4.0/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/test.js:134:1
    at processTicksAndRejections (internal/process/task_queues.js:89:5)

If using 11.x test command is ok.

@gingerhot

This comment has been minimized.

Copy link

@gingerhot gingerhot commented Jun 18, 2019

I'm using truffle-hdwallet-provider on Node.js 12, and same errors with scrypt as shown in the logs from CI above.

@filips123

This comment has been minimized.

Copy link
Contributor Author

@filips123 filips123 commented Jul 12, 2019

A quick solution is to use Yarn resolutions which should force correct new version. Note that it is only supported in Yarn (not NPM) and it will still produce error output (but it won't fail installation).

You need to add this to package.json:

{
  "resolutions": {
    "eth-lib/keccakjs/sha3": "^1.2.3",
    "web3/web3-eth/web3-eth-accounts/scrypt.js": "^0.3.0"
  }
}
@filips123

This comment has been minimized.

Copy link
Contributor Author

@filips123 filips123 commented Jul 27, 2019

This will probably be fixed in next version of Web3.

@DavidBurela

This comment has been minimized.

Copy link

@DavidBurela DavidBurela commented Aug 22, 2019

With the announcement of Web3 versioning, is there more that can now be said about node 12 support?

@tcoulter

This comment has been minimized.

Copy link
Contributor

@tcoulter tcoulter commented Aug 22, 2019

I was just going to inquire, @DavidBurela. I'll dig in and see what I can find.

@gnidan

This comment has been minimized.

Copy link
Member

@gnidan gnidan commented Aug 22, 2019

We're actively working on it. I believe ethereumjs-vm is the last piece of the puzzle.

@gnidan

This comment has been minimized.

Copy link
Member

@gnidan gnidan commented Aug 30, 2019

Can y'all try v5.0.34 to confirm working Node v12 support?

@DavidBurela

This comment has been minimized.

Copy link

@DavidBurela DavidBurela commented Sep 4, 2019

I still have issues.

Truffle v5.0.34 (core: 5.0.34)
Solidity v0.5.8 (solc-js)
Node v12.10.0
Web3.js v1.2.1

Repo steps:

truffle unbox metacaoin
truffle dev
test

truffle(develop)> test                                                                                                                      
Compiling your contracts...
===========================
> Compiling ./contracts/ConvertLib.sol
> Compiling ./contracts/MetaCoin.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./test/TestMetaCoin.sol

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL
    at process.<anonymous> (repl.js:224:15)
    at process.emit (events.js:214:15)
    at process.emit (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/build/webpack:/~/source-map-support/source-map-support.js:465:1)
    at _addListener (events.js:235:14)
    at process.addListener (events.js:283:10)
    at Runner.run (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:868:11)
    at Mocha.run (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:612:17)
    at /home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/test.js:116:1
    at new Promise (<anonymous>)
    at Object.run (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/test.js:115:1)     at processTicksAndRejections (internal/process/task_queues.js:93:5)
@roamabit

This comment has been minimized.

Copy link

@roamabit roamabit commented Oct 19, 2019

Currently working in Windows 10 - reloading node.js via .msi installer worked. https://nodejs.org/en/download/

Current specs:
Truffle 5.0.40
Node: 10.16.3
NPM 6.9.0

@trufflesuite trufflesuite deleted a comment from roamabit Nov 10, 2019
@gjgd

This comment has been minimized.

Copy link

@gjgd gjgd commented Nov 14, 2019

Status update: web3 supporting node 12 is a great step forward, but we still cannot use node 12 in our project because of @truffle/hdwallet-provider@1.0.25 depending on ethereumjs-wallet@0.6.3

Looks like ethereumjs-wallet being dependent to scrypt.js is the issue here

ethereumjs/ethereumjs-wallet#92

@johnda98

This comment has been minimized.

Copy link

@johnda98 johnda98 commented Nov 19, 2019

I still have issues.

Truffle v5.0.34 (core: 5.0.34)
Solidity v0.5.8 (solc-js)
Node v12.10.0
Web3.js v1.2.1

Repo steps:

truffle unbox metacaoin
truffle dev
test

truffle(develop)> test                                                                                                                      
Compiling your contracts...
===========================
> Compiling ./contracts/ConvertLib.sol
> Compiling ./contracts/MetaCoin.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./test/TestMetaCoin.sol

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException` cannot be used in the REPL
    at process.<anonymous> (repl.js:224:15)
    at process.emit (events.js:214:15)
    at process.emit (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/build/webpack:/~/source-map-support/source-map-support.js:465:1)
    at _addListener (events.js:235:14)
    at process.addListener (events.js:283:10)
    at Runner.run (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:868:11)
    at Mocha.run (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:612:17)
    at /home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/test.js:116:1
    at new Promise (<anonymous>)
    at Object.run (/home/david/.nvm/versions/node/v12.10.0/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/test.js:115:1)     at processTicksAndRejections (internal/process/task_queues.js:93:5)

yep same result here on as David B.. Im on ubuntu1604

all other parts of the suite work ok if on node v12+ ? i want to drizzle.. the tests i can do in remix on its in memory chain
johnda@ymirjda:~$ truffle version

Truffle v5.1.0 (core: 5.1.0)
Solidity v0.5.12 (solc-js)
Node v12.8.0
Web3.js v1.2.2
johnda@ymirjda:~$ "

@imehy3u

This comment has been minimized.

Copy link

@imehy3u imehy3u commented Nov 25, 2019

Same issue, easiest way out of this issue is to install node v11.15.0. As node v12 and v13 both will encounter the issue.

@ObjSal

This comment has been minimized.

Copy link

@ObjSal ObjSal commented Dec 4, 2019

This is not a solution, but a workaround while this is being fixed:

  1. Uninstall node
  2. Install nvm
  3. Install node v10 LTS by running: $ nvm install 10 --lts

The above will install node v10 long-term support

Now you can successfully run

$ truffle develop
> compile
> test

Hope it helps!

@johnda98

This comment has been minimized.

Copy link

@johnda98 johnda98 commented Dec 4, 2019

@adrianmcli

This comment has been minimized.

Copy link
Member

@adrianmcli adrianmcli commented Dec 4, 2019

What are the steps remaining to make this work on Node v12 (which is now also on LTS)?

@CruzMolina

This comment has been minimized.

Copy link
Member

@CruzMolina CruzMolina commented Dec 4, 2019

@adrianmcli see mochajs/mocha#4009.

Don't have the bandwidth currently to do so myself, but feel free to smoke test my fork of mocha (https://github.com/CruzMolina/mocha/tree/v5.2.1) with truffle bundled.

@ElYusubov

This comment has been minimized.

Copy link

@ElYusubov ElYusubov commented Jan 6, 2020

Is there any progress to make this work on Node v12 (which is currently on LTS)?

@johnda98

This comment has been minimized.

Copy link

@johnda98 johnda98 commented Jan 6, 2020

@CruzMolina

This comment has been minimized.

Copy link
Member

@CruzMolina CruzMolina commented Jan 10, 2020

Hey everyone!

We just published an experimental prerelease that uses a fork of mocha with one tiny change. 🤞

Our node 12 CI appears to be pleased and smoke testing locally w/ node 12 LTS seems to be fine.

Please give it a try and let us know if things work!

npm un -g truffle
npm i -g truffle@nodeLTS
@adriaanbd

This comment has been minimized.

Copy link

@adriaanbd adriaanbd commented Jan 11, 2020

Thanks for the lifesaver @CruzMolina, reporting success over here too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.