I'm trying to setup a webserver developed with typescript, and everything runs fine locally. No errors or warnings regarding usage or at runtime. I'm unable to deploy it to Azure, though;
// import inside website.ts
import { do_request } from "./api"
// breaks
do_request()
// function inside the module "api.ts"
export function do_request(name: string, data: any) {
// there is infact stuff in here
}
somewhere down the line, this happens:
2021-01-22T16:39:13.961567336Z $ cross-env NODE_ENV=production nodemon --exec ts-node src/index.ts -e ts
2021-01-22T16:39:14.997665938Z [33m[nodemon] 2.0.7[39m
2021-01-22T16:39:15.003697468Z [33m[nodemon] to restart at any time, enter `rs`[39m
2021-01-22T16:39:15.006837988Z [33m[nodemon] watching path(s): *.*[39m
2021-01-22T16:39:15.006861089Z [33m[nodemon] watching extensions: ts[39m
2021-01-22T16:39:15.006872090Z [32m[nodemon] starting `ts-node src/index.ts`[39m
2021-01-22T16:39:34.553414244Z ... environment: production
2021-01-22T16:39:38.264762256Z ... caching
2021-01-22T16:39:57.536570340Z ... finished
2021-01-22T16:39:59.879985595Z ... server listening on port 8080
2021-01-22T16:40:01.061256273Z ... azure storage directory ready
2021-01-22T17:03:33.811212805Z
2021-01-22T17:03:33.811396011Z /home/site/wwwroot/src/server/website.ts:150
2021-01-22T17:03:33.811428912Z do_request(requestType, json)
2021-01-22T17:03:33.811441213Z ^
2021-01-22T17:03:33.811449613Z TypeError: api_1.do_request is not a function
2021-01-22T17:03:33.811457813Z at IncomingMessage.<anonymous> (/home/site/wwwroot/src/server/website.ts:150:3)
2021-01-22T17:03:33.817172614Z at IncomingMessage.emit (node:events:388:22)
2021-01-22T17:03:33.817201815Z at IncomingMessage.EventEmitter.emit (node:domain:470:12)
2021-01-22T17:03:33.817210915Z at endReadableNT (node:internal/streams/readable:1295:12)
2021-01-22T17:03:33.817219316Z at processTicksAndRejections (node:internal/process/task_queues:80:21)
I have tried reinstalling all npm packages, switching node versions, switching imports;
// the same issue appears here, except it errors with "x has no constructor"
import Bot from "./bot"
// broken statement
const bot = new Bot()