Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Not usable on Node.js 12 #2070

Closed
filips123 opened this issue Jun 2, 2019 · 40 comments
Closed

Not usable on Node.js 12 #2070

filips123 opened this issue Jun 2, 2019 · 40 comments

Comments

@filips123
Copy link
Contributor

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 [email protected] which is used by eth-lib#keccakjs. To fix this, you need to update all dependencies yarn.lock. This should install [email protected] which has fixed compatibility with Node.js 12.

Another dependency with problems is [email protected] which is used by web3#web3-eth#web3-eth-accounts. It was fixed in [email protected]. Problem with this is that the fixed version is used only in [email protected] which is incompatible with Truffle (#1690). To fix this, you need to update Truffle to support [email protected] 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
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@hmijail
Copy link

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
Copy link

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
Copy link

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

@filips123
Copy link
Contributor Author

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
Copy link
Contributor Author

This will probably be fixed in next version of Web3.

@DavidBurela
Copy link

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

@tcoulter
Copy link
Contributor

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

@gnidan
Copy link
Contributor

gnidan commented Aug 22, 2019

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

@gnidan
Copy link
Contributor

gnidan commented Aug 30, 2019

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

@DavidBurela
Copy link

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
Copy link

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
Copy link

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/[email protected] depending on [email protected]

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

ethereumjs/ethereumjs-wallet#92

@johnda98
Copy link

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
Copy link

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
Copy link

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
Copy link

johnda98 commented Dec 4, 2019 via email

@adrianmcli
Copy link
Contributor

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

@CruzMolina
Copy link
Contributor

@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
Copy link

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

@johnda98
Copy link

johnda98 commented Jan 6, 2020 via email

@CruzMolina
Copy link
Contributor

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
Copy link

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

@jeffor12
Copy link

jeffor12 commented Feb 2, 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

Hey @CruzMolina can you plz help me with that? I have installed nodejs 12.14.1 ... how can I apply your solution? thx

@CruzMolina
Copy link
Contributor

Hi @jeffor12 !

You should be able to re-install the nodeLTS compatible (🤞) version of truffle via:

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

You can verify the nodeLTS release of truffle is node 12 compatible by running:

truffle unbox metacoin
truffle develop
develop> test

If the test run completes without throwing an error, you should be good to go.

@jeffor12
Copy link

jeffor12 commented Feb 4, 2020

Hi @CruzMolina!

I found a solution for my test error:
TypeError [ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException cannot be used in the REPL

I had to downgrade to node 10.18.1. then all went well...

@CruzMolina
Copy link
Contributor

Hey @jeffor12 ,

are you confirming that truffle@nodeLTS still throws that error?

Can you share your truffle version?

@jeffor12
Copy link

jeffor12 commented Feb 4, 2020

right now its
Truffle v5.1.11 (core: 5.1.11)
Solidity - 0.5.12 (solc-js)
Node v10.18.1
Web3.js v1.2.1

@CruzMolina
Copy link
Contributor

@jeffor12 , it sounds like you have truffle latest installed.

You'll need to npm un -g truffle && npm i -g truffle@nodeLTS to use truffle on node 12.

@SvenMeyer
Copy link

@CruzMolina thanks, that worked !
but why is the nodeLTS version not the default one? ... why are there two different versions?

@minimapletinytools
Copy link

Will this be fixed? Seems like a major issue.

Workaround does fix it for me.

@johnda98
Copy link

johnda98 commented Mar 7, 2020 via email

@guises2014
Copy link

This was a great and informative thread that helped me quickly understand my problem and find a resolution. My thanks to everyone involved.

@absenceofnunchi
Copy link

I've tried:

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

and have the following:

Truffle v5.1.14-nodeLTS.0 (core: 5.1.13)
Solidity - 0.5.0 (solc-js)
Node v13.12.0
Web3.js v1.2.1

but am still experiencing the error:

TypeError [ERR_INVALID_REPL_INPUT]: Listeners for uncaughtException cannot be used in the REPL

@mcosta-dns-pt
Copy link

Hey @CruzMolina!

Thanks! It worked here like a charm :)

@Mereep
Copy link

Mereep commented Jun 17, 2020

@CruzMolina
Thx, fixed the problem for me, too.

@RLNYC
Copy link

RLNYC commented Jul 22, 2020

@CruzMolina
I also gets compilation error:

TypeError: Error parsing C:/Users/.../contracts/Migrations.sol: Cannot destructure property 'body' of 'undefined' as it is undefined.

@haltman-at
Copy link
Contributor

@RLNYC: That seems like an unrelated error. Would you mind opening a new issue and elaborating on it there? Thanks!

Meanwhile, I'm going to close this issue as it should be resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.