2
let app = require('lotion')({
  initialState: { count: 0 }
})

app.use((state, tx) => {
  state.count++
})

app.listen(3000)

On running this code (which I found on the lotion js official website), I am getting this error

/home/kashika/node_modules/supercop.js/lib.js:97
  throw ex;
  ^

TypeError: app.listen is not a function
    at Object.<anonymous> (/home/kashika/prog.js:9:5)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
KSH
  • 21
  • 3

1 Answers1

0

As Lotion owner said:

Also, I removed the dependency that was breaking your install on Node 11, it should work on either version now (though you may still see some weird warnings on 11, I'd recommend using 10).

Solution:

Remove node_modules directory and try to install again latest version of lotion

create app.js and replace:

let lotion = require('lotion')

let app = lotion({
    initialState: {
        count: 0
    }
})

function transactionHandler(state, transaction) {
    if (state.count === transaction.nonce) {
        state.count++
    }
}

app.use(transactionHandler)

app.start().then(appInfo => console.log(appInfo.GCI))

then run node app.js will solve

Mohammad Fanni
  • 4,095
  • 3
  • 28
  • 52