Azure生产类型脚本导入失败



我试图设置一个web服务器与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()

要部署到哪个Azure服务?Azure功能?

而且,你现在是怎么做的?在VS Code或CLI中使用Azure Functions核心工具。你试过https://github.com/mhoeger/typescript-azure-functions#deploy吗?

最新更新