0

I am trying to deploy a chess telegram bot for which the developer has a demo and it works well. However that code has a mistake in that black and white pieces are reversed and bishop and pawn are interchanged for both colours.

So I decided to fork it and corrected that error and figured I will host it myself to test and this is where I am stuck as I don't know much about the node - npm world. I have tried to get it to a point where heroku compiles it all without error:

heroku build and deployment succeed

but then this code uses knex module and if I try and run on my local machine the recommended npm run knex migrate:latestfrom original author it throws the error npm ERR! missing script: knex.

Local npm error

The fork that I have created is available here: https://github.com/pubmania/chessbot I have set the following environment variables on heroku:

Config Vars

This is again in line with guidance from original author.

Initially when I tried to create the dyno I was getting "no node engine" so I added the node engine with latest node version in package.json and then it gave the error "no start script" error so I added the start script in package.json which is essentially the same as "dev" but this took that error away. Now the log on heroku shows the below entries:

2020-05-05T10:31:34.714232+00:00 app[web.1]:     at Object.<anonymous> (/app/src/index.js:23:23)
2020-05-05T10:31:34.714233+00:00 app[web.1]:     at Module._compile (internal/modules/cjs/loader.js:1133:30)
2020-05-05T10:31:34.714233+00:00 app[web.1]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
2020-05-05T10:31:34.714233+00:00 app[web.1]:     at Module.load (internal/modules/cjs/loader.js:977:32)
2020-05-05T10:31:34.714234+00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:877:14) {
2020-05-05T10:31:34.714234+00:00 app[web.1]:   code: 'MODULE_NOT_FOUND',
2020-05-05T10:31:34.714234+00:00 app[web.1]:   requireStack: [ '/app/src/index.js' ]
2020-05-05T10:31:34.714235+00:00 app[web.1]: }
2020-05-05T10:31:34.741594+00:00 app[web.1]: [31m[nodemon] app crashed - waiting for file changes before starting...[39m
2020-05-05T10:32:30.546060+00:00 heroku[web.1]: State changed from starting to crashed

I tried running the npm run knex migrate:latest command from heroku bash and I still got the same error as can be seen in screenshot below.

enter image description here

I was reading a bit more and added the following under scripts section of package.json

"knex": "node_modules/.bin/knex migrate:latest"

and then running the npm run knex on local gave

sqlite does not support inserting default values. Set the `useNullAsDefault` flag to hide this warning. (see docs http://knexjs.org/#Builder-insert).

which perhaps is explainable by the fact that on local i am using sqlite so i just ran heroku local web but that gave the error:

13:31:24 web.1   |  > chessbot@1.0.0 start C:\a-chess-bot-git\chessbot
13:31:24 web.1   |  > nodemon -w src src/index.js
13:31:25 web.1   |  [nodemon] 1.19.4
13:31:25 web.1   |  [nodemon] to restart at any time, enter `rs`
13:31:25 web.1   |  [nodemon] watching dir(s): src\**\*
13:31:25 web.1   |  [nodemon] watching extensions: js,mjs,json
13:31:25 web.1   |  [nodemon] starting `node src/index.js`
13:31:25 web.1   |  internal/modules/cjs/loader.js:960
13:31:25 web.1   |    throw err;
13:31:25 web.1   |    ^
13:31:25 web.1   |  Error: Cannot find module 'C:\a-chess-bot-git\chessbot\src\scenes'
13:31:25 web.1   |  Require stack:
13:31:25 web.1   |  - C:\a-chess-bot-git\chessbot\src\index.js
13:31:25 web.1   |      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
13:31:25 web.1   |      at Function.Module._resolveFilename (C:\a-chess-bot-git\chessbot\node_modules\module-alias\index.js:49:29)
13:31:25 web.1   |      at Function.Module._load (internal/modules/cjs/loader.js:840:27)
13:31:25 web.1   |      at Module.require (internal/modules/cjs/loader.js:1019:19)
13:31:25 web.1   |      at require (internal/modules/cjs/helpers.js:77:18)
13:31:25 web.1   |      at Object.<anonymous> (C:\a-chess-bot-git\chessbot\src\index.js:23:23)
13:31:25 web.1   |      at Module._compile (internal/modules/cjs/loader.js:1133:30)
13:31:25 web.1   |      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
13:31:25 web.1   |      at Module.load (internal/modules/cjs/loader.js:977:32)
13:31:25 web.1   |      at Function.Module._load (internal/modules/cjs/loader.js:877:14) {
13:31:25 web.1   |    code: 'MODULE_NOT_FOUND',
13:31:25 web.1   |    requireStack: [
13:31:25 web.1   |      'C:\\a-chess-bot-git\\chessbot\\src\\index.js'
13:31:25 web.1   |    ]
13:31:25 web.1   |  }
13:31:25 web.1   |  [nodemon] app crashed - waiting for file changes before starting

Any help on getting this deployed on heroku will be hugely appreciated.

techbolt
  • 103
  • 8

1 Answers1

0

Upon reading further and diving a bit into the code on the "master" branch, I realised that the problem was with the code missing some index.js files. The repo I forked it from had a "backup" branch and using that seems to have worked although it was still not working as expected and was crashing.

I finally gave up and deleted the forked repo and will be trying again when I have some spare time but the issue above was most definitely closed and I will leave it here in hope that someone might find it useful.

techbolt
  • 103
  • 8