handshake-org / hsd

Handshake Daemon & Full Node
Other
1.93k stars 278 forks source link

nodejs v15 is NOT supported #577

Open 0xtoko opened 3 years ago

0xtoko commented 3 years ago

I can't seem to run hsd on mac. Already ran npm install and also reinstalled leveldown but no luck. Any suggestions?

Followed instructions from: https://handshake.org/claim/

OS: Mac Big Sur (11.2.2) leveldown@5.6.0 node@v15.11.0

takuma@MacBook-Pro hsd % ./bin/hsd --log-level info
/Users/takuma/Documents/vscode Projects/handshake/hsd-2.3.0/hsd/node_modules/loady/lib/loady.js:156
  throw err;
  ^

Error: Cannot find module 'leveldown.node'
    at moduleError (/Users/takuma/Documents/vscode Projects/handshake/hsd-2.3.0/hsd/node_modules/loady/lib/loady.js:154:15)
    at resolve (/Users/takuma/Documents/vscode Projects/handshake/hsd-2.3.0/hsd/node_modules/loady/lib/loady.js:89:9)
    at load (/Users/takuma/Documents/vscode Projects/handshake/hsd-2.3.0/hsd/node_modules/loady/lib/loady.js:99:16)
    at Object.<anonymous> (/Users/takuma/Documents/vscode Projects/handshake/hsd-2.3.0/hsd/node_modules/bdb/lib/level.js:9:33)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18) {
  code: 'MODULE_NOT_FOUND'
}
pinheadmz commented 3 years ago

You might have to stick with node 14 -- what was the output of npm install ?

0xtoko commented 3 years ago

No errors. Will try downgrading node.

takuma@MacBook-Pro hsd % npm install

up to date, audited 47 packages in 2s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
pinheadmz commented 3 years ago

also try npm rebuild -- it should compile levelDB (written in C++) and produce the leveldown.node file that appears missing

0xtoko commented 3 years ago

downgrading node to 14.16.0 and running npm install and npm rebuild did the trick! Thanks.

pinheadmz commented 3 years ago

Good to know, thanks. Closing for now... we'll have to address new versions of node eventually.

lyoshenka commented 3 years ago

I had this same problem on hsd v2.4 with node v14.17.0. I fixed it by going into a few node_modules and running node-gyp configure && node-gyp build. The modules were bdb, bcrypto, goosig, mrmr.

Hope this helps others experiencing this issue

pinheadmz commented 3 years ago

@lyoshenka you would have to rebuild after switching nodejs versions - was this your case?

I'm going to reopen this and pin it as a FAQ.

lyoshenka commented 3 years ago

rebuild did not help, but I now understand what happened: i have post-install scripts disabled (because of this) so node-gyp is never called and never builds the .node files.

nkoehring commented 3 years ago

@lyoshenka 's approach worked for me with Node16.7.0. I had to install unbound dev package, then I ran something like:

cd node_modules
for gyp in $(ls */binding.gyp)
do
  dir=${gyp%binding.gyp}
  cd $dir && node-gyp configure && node-gyp && cd -
done
pinheadmz commented 3 years ago

Thanks @nkoehring I'm also looking into an issue on Big Sur with the new Apple M1 chip. Homebrew installs libraries like unbound in a new location /opt/homebrew and I'm not sure how to handle this yet. My system was migrated from an older Mac so I still have the Intel-compiled unbound in /usr/local, node-gyp seems to find it ok there and is able to link. However users who are installing hsd on a brand new computer with the latest version of homebrew might have an issue linking to unbound in the new location.

rberger commented 2 years ago

@nkoehring 's technique worked for me on an Intel Mac running macOS Monterey, except I had to have the second node-gyp be nod-gyp build and I had to ensure that the libtool being used was the one from xtools / builtin to macOS and not gnu libtools from homebrew.

export PATH=/usr/bin:$PATH # Ensure the builtin  libtool was used
cd node_modules
for gyp in $(ls */binding.gyp)
do
  dir=${gyp%binding.gyp}
  cd $dir && node-gyp configure && node-gyp build && cd - # Added build as the argument to the second node-gyp
done
bitcoinbrisbane commented 2 years ago

Worked for me too.

bitcoinbrisbane commented 2 years ago

Can we upgrade this ticket to Node 16.x?