【发布时间】:2021-01-22 17:05:17
【问题描述】:
我正在尝试设置一个使用 typescript 开发的网络服务器,并且一切都在本地运行良好。没有关于使用或运行时的错误或警告。不过,我无法将它部署到 Azure;
// 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
}
在某个地方,会发生这种情况:
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)
我尝试过重新安装所有 npm 包,切换节点版本,切换导入;
// the same issue appears here, except it errors with "x has no constructor"
import Bot from "./bot"
// broken statement
const bot = new Bot()
【问题讨论】:
标签: typescript azure