bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.88k stars 2.09k forks source link

Bitcored 5.0 beta4 fails to start #1470

Open got3nks opened 7 years ago

got3nks commented 7 years ago

After installing Bitcore from the beta channel,

npm install -g bitcore@beta

This is the output of bitcored, failing to start:

bitcore@g33:~$ bitcored
[2017-08-30T13:41:13.490Z] info: Checked the current working directory for service: address
[2017-08-30T13:41:13.496Z] info: Checked the current working directory for service: block
[2017-08-30T13:41:13.518Z] error: ReferenceError: Invalid left-hand side in assignment
[2017-08-30T13:41:13.518Z] info: Checked the built-in path: lib/services, for service: block
[2017-08-30T13:41:13.519Z] info: Checked the module's package.json for service: block
/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/scaffold/start.js:149
    throw new Error('Attempted to load the ' + service.name + ' service from: ' +
    ^

Error: Attempted to load the block service from: the requirePath in the services' config, then "/home/bitcore" then from: "/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/scaffold/../lib/services" finally from: "/home/bitcore/package.json" - bitcoreNode field. All paths failed to find valid nodeJS code.
    at loadModule (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/scaffold/start.js:149:11)
    at Function.setupServices (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/scaffold/start.js:188:7)
    at start (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/scaffold/start.js:25:31)
    at Object.main [as daemon] (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/cli/daemon.js:34:3)
    at Liftoff.<anonymous> (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/cli/bitcored.js:32:16)
    at Liftoff.<anonymous> (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/node_modules/liftoff/index.js:202:12)
    at Liftoff.<anonymous> (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/node_modules/liftoff/index.js:169:7)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)
    at Function.Module.runMain (module.js:443:11)
unixfox commented 7 years ago

I've the same issue but creating a dedicated directory for bitcore resolved the issue: bitcore create mynode.

got3nks commented 7 years ago

I tried your suggestion.

bitcore create bcashnode cd bcashnode bitcored

I was getting this error:

[2017-08-31T22:58:21.775Z] info: Checked the current working directory for service: address
[2017-08-31T22:58:21.785Z] info: Checked the current working directory for service: block
[2017-08-31T22:58:21.910Z] info: Checked the current working directory for service: db
[2017-08-31T22:58:21.933Z] info: Checked the current working directory for service: fee
[2017-08-31T22:58:21.938Z] info: Checked the current working directory for service: header
[2017-08-31T22:58:21.955Z] info: Checked the current working directory for service: mempool
[2017-08-31T22:58:21.957Z] info: Checked the current working directory for service: p2p
[2017-08-31T22:58:22.053Z] info: Checked the current working directory for service: timestamp
[2017-08-31T22:58:22.063Z] info: Checked the current working directory for service: transaction
[2017-08-31T22:58:22.065Z] info: Checked the current working directory for service: web
[2017-08-31T22:58:22.065Z] info: Checked the current working directory for service: node_modules/insight-api
[2017-08-31T22:58:22.066Z] info: Checked the built-in path: lib/services, for service: insight-api
[2017-08-31T22:58:22.066Z] info: Checked the module's package.json for service: insight-api
/home/bitcore/bcashnode/node_modules/bitcore-node/lib/scaffold/start.js:149
    throw new Error('Attempted to load the ' + service.name + ' service from: ' +
    ^

Error: Attempted to load the insight-api service from: the requirePath in the services' config, then "/home/bitcore/bcashnode" then from: "/home/bitcore/bcashnode/node_modules/bitcore-node/lib/scaffold/../lib/services" finally from: "/home/bitcore/bcashnode/package.json" - bitcoreNode field. All paths failed to find valid nodeJS code.
    at loadModule (/home/bitcore/bcashnode/node_modules/bitcore-node/lib/scaffold/start.js:149:11)
    at Function.setupServices (/home/bitcore/bcashnode/node_modules/bitcore-node/lib/scaffold/start.js:188:7)
    at start (/home/bitcore/bcashnode/node_modules/bitcore-node/lib/scaffold/start.js:25:31)
    at Object.main [as daemon] (/home/bitcore/bcashnode/node_modules/bitcore-node/lib/cli/daemon.js:34:3)
    at Liftoff.<anonymous> (/usr/lib/node_modules/bitcore/node_modules/bitcore-node/lib/cli/bitcored.js:29:16)
    at Liftoff.<anonymous> (/usr/lib/node_modules/bitcore/node_modules/liftoff/index.js:202:12)
    at Liftoff.<anonymous> (/usr/lib/node_modules/bitcore/node_modules/liftoff/index.js:169:7)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    at Function.Module.runMain (module.js:611:11)

After installing the following: npm install insight-api@beta npm install insight-ui@beta

I can finally run Bitcore v5.0 beta 4!

unixfox commented 7 years ago

Thank you that did the trick for me!

xishoon commented 7 years ago

if we install bitcore walllet service under our new node and than start server it is still throwing following error, any thoughts?

error: uncaught exception: { AssertionError [ERR_ASSERTION]: Required dependency "insight-api" not available. at addToStack (/home/zeshan/amaano-beta/node_modules/bitcore-node/lib/node.js:100:7) at addToStack (/home/zeshan/amaano-beta/node_modules/bitcore-node/lib/node.js:102:7) at Node._getServiceOrder (/home/zeshan/amaano-beta/node_modules/bitcore-node/lib/node.js:112:3) at Node.start (/home/zeshan/amaano-beta/node_modules/bitcore-node/lib/node.js:183:28) at start (/home/zeshan/amaano-beta/node_modules/bitcore-node/lib/scaffold/start.js:40:8) at Object.main [as daemon] (/home/zeshan/amaano-beta/node_modules/bitcore-node/lib/cli/daemon.js:34:3) at Liftoff. (/home/zeshan/.nvm/versions/node/v8.3.0/lib/node_modules/bitcore/node_modules/bitcore-node/lib/cli/bitcored.js:29:16)

got3nks commented 7 years ago

Look my previous post, try running:

npm install insight-api@beta
npm install insight-ui@beta
xishoon commented 7 years ago

@got3nks I already had installed these dependencies before installing wallet service. thanks

unixfox commented 7 years ago

@xishoon Here's what I followed when I installed bitcoin wallet service with bitcore v5:

  1. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
  2. sudo apt-get install libzmq3-dev build-essential mongodb libkrb5-dev -y
  3. exit then su <users>
  4. nvm install v8 && nvm use v8
  5. npm install -g bitcore@beta
  6. bitcore create mynode && cd mynode
  7. npm install bitcore-wallet-service
  8. npm install insight-api@beta
  9. npm uninstall --prefix /home/<users/mynode/node_modules/bitcore-wallet-service -S bitcore-lib (https://github.com/bitpay/bitcore-wallet-service/issues/643#issuecomment-317205489)
  10. Adding
    "bitcore-wallet-service",
    "insight-api",

    to my bitcore-node.json (https://hastebin.com/pegomedipi.json)

  11. bitcored

Maybe you could check if you missed something by comparing the commands with what you did for installing wallet service or reinstall from scratch with my commands.

xishoon commented 7 years ago

thanks @unixfox. Bitcore server is running now but when I add following to my bitcore-node.json "bitcore-wallet-service", "insight-api", Following error is coming. Any thoughts?

Error

[2017-10-11T07:37:40.617Z] error: Error: Unknown network at Service._getConfiguration (/home/zeshan/mynode/node_modules/bitcore-wallet-service/bitcorenode/index.js:99:11)

Logs:

zeshan@zeshan-Latitude-E6420:~/mynode/data$ bitcored [2017-10-11T07:37:37.591Z] info: Checked the current working directory for service: address [2017-10-11T07:37:37.597Z] info: Checked the current working directory for service: block [2017-10-11T07:37:37.685Z] info: Checked the current working directory for service: db [2017-10-11T07:37:37.713Z] info: Checked the current working directory for service: bitcore-wallet-service [2017-10-11T07:37:37.713Z] info: Checked the built-in path: lib/services, for service: bitcore-wallet-service [2017-10-11T07:37:38.399Z] info: Checked the current working directory for service: node_modules/insight-api [2017-10-11T07:37:38.399Z] info: Checked the built-in path: lib/services, for service: insight-api [2017-10-11T07:37:38.675Z] info: Checked the current working directory for service: fee [2017-10-11T07:37:38.679Z] info: Checked the current working directory for service: header [2017-10-11T07:37:38.682Z] info: Checked the current working directory for service: mempool [2017-10-11T07:37:38.684Z] info: Checked the current working directory for service: p2p [2017-10-11T07:37:38.715Z] info: Checked the current working directory for service: timestamp [2017-10-11T07:37:38.716Z] info: Checked the current working directory for service: transaction [2017-10-11T07:37:38.718Z] info: Checked the current working directory for service: web [2017-10-11T07:37:38.719Z] info: Using config: /home/zeshan/mynode/bitcore-node.json [2017-10-11T07:37:38.719Z] info: Using network: livenet [2017-10-11T07:37:38.720Z] info: Starting db [2017-10-11T07:37:38.724Z] info: Starting timestamp [2017-10-11T07:37:38.883Z] info: Starting p2p [2017-10-11T07:37:38.893Z] info: Peers not explicitly configured, starting a local bcoin node. [2017-10-11T07:37:39.078Z] info: Starting Bcoin full node... [info] (chain) Chain is loading. [info] (chain) Checkpoints are enabled. [info] (chaindb) Opening ChainDB... [info] (chaindb) Writing genesis block to ChainDB. [info] (chaindb) ChainDB successfully initialized. [info] (chaindb) Chain State: hash=000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f tx=1 coin=0 value=0.0. [info] (chain) Chain Height: 0 [info] (mempool) Mempool loaded (maxsize=97656.25kb). [info] (miner) Miner loaded (flags=mined by bcoin). [warning] (miner) No reward address is set for miner! [info] (net) Pool loaded (maxpeers=8). [info] (net) Initialized header chain to height 0 (checkpoint=0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d). [info] (http) Node HTTP server listening on 127.0.0.1 (port=8332). [info] (node) Node is loaded. [info] (net) External IPv4 found (http): 103.7.79.177. [info] (net) Adding loader peer (82.200.204.41:8333). [info] (net) Pool server listening on 0.0.0.0 (port=8333). [2017-10-11T07:37:40.576Z] info: Waiting for Bcoin to sync [2017-10-11T07:37:40.577Z] info: Starting header [2017-10-11T07:37:40.584Z] info: Starting block [2017-10-11T07:37:40.588Z] info: Starting mempool [2017-10-11T07:37:40.590Z] info: localhost-mempool subscribe: p2p/transaction total: 1 [2017-10-11T07:37:40.590Z] info: Starting transaction [2017-10-11T07:37:40.591Z] info: Starting address [2017-10-11T07:37:40.592Z] info: Starting web [2017-10-11T07:37:40.613Z] info: Starting fee [2017-10-11T07:37:40.614Z] info: Starting insight-api [2017-10-11T07:37:40.614Z] info: localhost-insight-api subscribe: p2p/transaction total: 2 [2017-10-11T07:37:40.614Z] info: localhost-insight-api subscribe: p2p/block total: 1 [2017-10-11T07:37:40.615Z] info: Starting bitcore-wallet-service [2017-10-11T07:37:40.615Z] error: Failed to start services [2017-10-11T07:37:40.617Z] error: Error: Unknown network at Service._getConfiguration (/home/zeshan/mynode/node_modules/bitcore-wallet-service/bitcorenode/index.js:99:11) at Service.start (/home/zeshan/mynode/node_modules/bitcore-wallet-service/bitcorenode/index.js:136:19) at Node._startService (/home/zeshan/mynode/node_modules/bitcore-node/lib/node.js:138:11) at /home/zeshan/mynode/node_modules/bitcore-node/lib/node.js:190:12 at /home/zeshan/mynode/node_modules/async/dist/async.js:3083:16 at replenish (/home/zeshan/mynode/node_modules/async/dist/async.js:946:17) at iterateeCallback (/home/zeshan/mynode/node_modules/async/dist/async.js:931:17) at /home/zeshan/mynode/node_modules/async/dist/async.js:906:16 at /home/zeshan/mynode/node_modules/bitcore-node/lib/node.js:165:5 at InsightAPI.start (/home/zeshan/mynode/node_modules/insight-api/lib/index.js:109:3) [2017-10-11T07:37:40.617Z] info: Beginning shutdown [2017-10-11T07:37:40.617Z] warn: Node is stopping, gently closing the database. Please wait, this could take a while. [2017-10-11T07:37:40.618Z] info: P2P Service: disconnecting pool and peers. SIGINT issued, system shutdown initiated [2017-10-11T07:37:40.618Z] info: Stopping bitcore-wallet-service [2017-10-11T07:37:40.618Z] info: Stopping insight-api [2017-10-11T07:37:40.618Z] info: Stopping fee [2017-10-11T07:37:40.618Z] info: Stopping web [2017-10-11T07:37:40.619Z] info: Stopping address [2017-10-11T07:37:40.619Z] info: Stopping transaction [2017-10-11T07:37:40.619Z] info: Stopping mempool [2017-10-11T07:37:40.619Z] info: Stopping block [2017-10-11T07:37:40.620Z] info: Stopping header [2017-10-11T07:37:40.620Z] info: Stopping p2p [info] (net) Removed loader peer (82.200.204.41:8333). [info] (net) Initialized header chain to height 0 (checkpoint=0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d). [info] (node) Node is closed.

unixfox commented 7 years ago

@xishoon Replace the lines 90 to 100 for this file /home/zeshan/mynode/node_modules/bitcore-wallet-service/bitcorenode/index.js with these:

 baseConfig.blockchainExplorerOpts = {
      livenet: providerOptions
    };

I've already tried this solution: https://github.com/bitpay/bitcore/issues/1461#issuecomment-318700544 but that doesn't work so that's why I made this dirty patch.

xishoon commented 7 years ago

@unixfox Superb... Its working now :+1:

ydaniels commented 7 years ago

dude @unixfox this comment should be a blog post on its own better than the official guide

hortonelectric commented 5 years ago

In Dec 2018 this no longer works.

Error: Attempted to load the bitcoind service from: the requirePath in the servi
ces' config, then "/home/ubuntu/bws" then from: "/home/ubuntu/bws/node_modules/b
itcore-node/lib/scaffold/../lib/services" finally from: "/home/ubuntu/bws/packag
e.json" - bitcoreNode field. All paths failed to find valid nodeJS code.

The bitcore-node.json is as follows:

{
  "version": "5.0.1-alpha",
  "network": "livenet",
  "port": 3001,
  "services": [
    "bitcoind",
    "address",
    "block",
    "db",
    "fee",
    "header",
    "mempool",
    "p2p",
    "timestamp",
    "transaction",
    "web",
    "bitcore-wallet-service",
    "insight-api"
  ],
  "datadir": "/home/ubuntu/.bitcore/data",
  "servicesConfig": {
    "insight-api": {
      "cwdRequirePath": "node_modules/insight-api"
    },
    "insight-ui": {
      "cwdRequirePath": "node_modules/insight-ui"
    },
    "bitcoind": {
      "spawn": {
        "datadir": "/home/ubuntu/.bitcoin",
        "exec": "/home/ubuntu/bitcoin/src/bitcoind"
      }
    }
  }
}
raucao commented 5 years ago

The current beta is v8, and it lives in the v8.0.0 branch. It would really be useful to document this properly on the website and for people arriving at this repo.

In fact, is there a reason why v8.0.0 isn't the default branch in this repo? Or why it's not developed in master in the first place? Could create a "stable" or "legacy" or "v4" or whatever branch, for the code that nobody actually maintains anymore.