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

This package appears to require specially node9 on amazon linux? #184

Open
joepagan opened this issue Nov 25, 2018 · 6 comments
Open

This package appears to require specially node9 on amazon linux? #184

joepagan opened this issue Nov 25, 2018 · 6 comments

Comments

@joepagan
Copy link

joepagan commented Nov 25, 2018

Having an issue with a couple of node packages that require node-scrypt on my amazon linux server.

This works fine on Macos 10.14.1 locally on other node versions.

It looks like scrypt requires at least node version 9 to higher, decided to look at NODE_MODULE_VERSION, 59 is node 9.

I get the following error on node 8.13.0 and similar on node6,7 & 11:

Error: The module '/var/www/site/shared/node_modules/truffle-hdwallet-provider/node_modules/scrypt/build/Release/scrypt.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 59. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:683:18)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.<anonymous> (/var/www/site/shared/node_modules/truffle-hdwallet-provider/node_modules/scrypt/index.js:3:20)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.<anonymous> (/var/www/site/shared/node_modules/truffle-hdwallet-provider/node_modules/scrypt.js/node.js:1:76)
    at Module._compile (internal/modules/cjs/loader.js:654:30)

node-gyp is installed globally

This appears to be a dependency of https://github.com/trufflesuite/truffle-hdwallet-provider & https://github.com/ethereum/web3.js/

I have rebuilt/installed several times after:

  • I have runrm -rf node_modules/*, npm i --no-package-lock, incase my package-lock.json made on macos installed a different package.
  • Added scypt and scrypt.js as project dependencies, then creating symlinks inside all the package dependencies that have a scrypt and scrypt.js dependency to node_modules/scrypt and node_modules/scrypt.js which doesn't actually resolve the issue. As suggested here: blockTime > 2 causes contract code not be stored; --allowUnlimitedContractSize has no effect; trufflesuite/ganache#134 (comment)
  • Tried to switch to different versions of node and have rebuilt my packages, node 6, node 7 & node 8 --lts all do the same:
  • tried npm install --unsafe-perm --no-package-lock
  • Changing /usr/bin/gcc to use a symlink to gcc44 instead of gcc48
  • Installing scrypt globally

similar issue:
trufflesuite/ganache#134

@joepagan joepagan changed the title Issue on amazon linux This package appears to require node9 or above? Nov 25, 2018
@joepagan joepagan changed the title This package appears to require node9 or above? This package appears to require specially node9 on amazon linux? Nov 25, 2018
@imthatcarlos
Copy link

@joepagan Looks I'm having the same issue. Have you had any luck? This is the last leg of my 2-day-long AWS deployment

> node build/server.js --network ropsten --db staging

module.js:682
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: The module '/var/node_modules/web3/node_modules/scrypt/build/Release/scrypt.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (module.js:682:18)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/node_modules/web3/node_modules/scrypt/index.js:3:20)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)

@joepagan
Copy link
Author

joepagan commented Dec 12, 2018

@imthatcarlos nope, my temp fix was to node9-ify my app. Luckily there wasn't too much to do in my case. For you it looks like you'd be downgrading though!

Specifically this was happening on Amazon Linux 1 for me, so it might be worth trying Amazon Linux 2? Or even try centos/alpine if you've got a container setup. (I'm not there yet with mine)

I was hoping that this issue might be addressed, though looking at the master branch, last commit was like 2 years ago so going to have to find another solution, or, maybe try get the ethereum devs to stop using this as a dependency.

@imthatcarlos
Copy link

Hmm.. Ok. I tried to include the package in my dependencies and realized you also did.
Now, I've removed node_modules/ from my .ebignore file, and I'm getting a slew of other issues in the ec2 instance logs. Dealing now 😄

@imthatcarlos
Copy link

imthatcarlos commented Dec 17, 2018

For reference, here's what I had to do:

  • to deal with this original issue, I removed node_modules/ from .ebignore to include all my packages in the source zip for eb
  • I included "bcrypt": "^3.0.2", and "scrypt": "^6.0.3" in my dependencies
  • I saw errors in /var/log/eb-activity.log on my ec2 instance related to scrypt and bcrypt , so I decided to install both packages on the server during a elastic beanstalk post hook in .ebextensions/01_build.config:
files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99_build_app.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      cd /var/app/current/
      rm -rf node_modules/bcrypt
      sudo /opt/elasticbeanstalk/node-install/node-v10.13.0-linux-x64/bin/npm install bcrypt@latest
      sudo /opt/elasticbeanstalk/node-install/node-v10.13.0-linux-x64/bin/npm install scrypt@latest
  • I then saw errors in regarding missing files in some packages, one being truffle-hdwallet-provider:
Error: Cannot find module '../contracts/GlobalRegistrar.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/var/app/current/node_modules/truffle-hdwallet-provider/node_modules/web3/lib/web3/namereg.js:23:26)
  • And they were indeed missing (still not sure why), so I manually moved them to the server:
scp -rp -i /Users/carlos/.ssh/aws-eb ./node_modules/truffle-hdwallet-provider/node_modules/web3/lib/contracts/ ec2-user@ip:/usr/...

Had to do that last step for truffle-contract and web3-eth-ens. Deploying this dapp to EB has been a bit of a headache 😓

@joepagan
Copy link
Author

joepagan commented Dec 17, 2018

Jesus, don't understand why you're getting behaviour like that, very strange, what a nightmare!

Grateful that you have posted the steps, very much appreciated, thank you. I did want to EB mine too so I'll try follow these steps and see if I get any luck on node10 EB.

@imthatcarlos
Copy link

Sure thing, let me know how it goes!

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

No branches or pull requests

2 participants