bigchaindb / js-bigchaindb-driver

Official BigchainDB JavaScript driver for Node.js and the browser
https://docs.bigchaindb.com/projects/js-driver/en/latest/usage.html
Apache License 2.0
216 stars 92 forks source link

Error: Cannot find module 'bigchaindb-driver' #296

Closed drj1990 closed 5 years ago

drj1990 commented 5 years ago

Hello,

I am not able to make transaction to bigchaindb with node js. I have installed the npm module for bigchaindb by below command.

npm install bigchaindb-driver I am using below code for writing transaction in a file app.js

const driver = require('bigchaindb-driver')

const alice = new driver.Ed25519Keypair()
const conn = new driver.Connection('http://35.225.89.2:9984/api/v1/')
const tx = driver.Transaction.makeCreateTransaction(
    { message: 'Blockchain all the things!' },
    null,
    [ driver.Transaction.makeOutput(
        driver.Transaction.makeEd25519Condition(alice.publicKey))],
    alice.publicKey)
const txSigned = driver.Transaction.signTransaction(tx, alice.privateKey)
conn.postTransactionCommit(txSigned)

But when i run the file in node as node app.js then i get error as

Error: Cannot find module 'bigchaindb-driver'

I have tried installing others module but they work fine.

stefanvangastel commented 5 years ago

Same with latest version bigchaindb-driver@4.1.1, now using 4.1.0 as fallback that works.

drj1990 commented 5 years ago

@stefanvangastel Thanks for sharing the information. I used version 4.1.0 and i am getting this error

/home/dhiraj/node_modules/base-x/index.js:29
    if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer')
                                  ^

TypeError: Expected Buffer
    at Object.encode (/home/dhiraj/node_modules/base-x/index.js:29:41)
    at new Ed25519Keypair (/home/dhiraj/node_modules/bigchaindb-driver/dist/node/Ed25519Keypair.js:28:33)
    at Object.<anonymous> (/home/dhiraj/test.js:7:15)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)

I am using node code from below link https://github.com/bigchaindb/js-bigchaindb-driver

stefanvangastel commented 5 years ago

I experienced the same issue, had to pin base-x and bip39 to specific versions due to outdated docs on bigchaindb-driver (And I'm lacking the knowhow to improve the docs):

 "dependencies": {
    "bigchaindb-driver": "4.1.0",
    "bip39": "^2.5.0",
    "base-x": "3.0.4"
  }
drj1990 commented 5 years ago

@stefanvangastel Thanks for information. This seem to worked for me. Do you think it is worth spending time on bigchaindb as it is not production ready.

drj1990 commented 5 years ago

I experienced the same issue, had to pin base-x and bip39 to specific versions due to outdated docs on bigchaindb-driver (And I'm lacking the knowhow to improve the docs):

 "dependencies": {
    "bigchaindb-driver": "4.1.0",
    "bip39": "^2.5.0",
    "base-x": "3.0.4"
  }

Above solution worked for me.