typescript - CircleCI 无法评估 TypeScript
问题描述
我有一个前端和后端都是打字稿的项目。所有测试都在本地通过,但是,当推送到 github 上的分支时,它总是在 TypeScript 的第一个迹象时失败(在后端,现在我只专注于后端测试)。
SyntaxError: /home/circleci/project/server/src/User-Server/server.ts: Unexpected token (16:35)
14 | app.use(apiRoutes);
15 |
> 16 | module.exports = app.listen(PORT, (): void => {
| ^
17 | console.log(` Server listening on port ${PORT} - ${ENV} environment`);
18 | });
19 |
这是我的 config.yml:
version: 2
jobs:
build:
docker:
- image: circleci/node:10.15.3
# working_directory: ~/repo
steps:
- checkout
#download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- run: npm test
我也将此发布到CircleCI 讨论论坛。
我的 tsconfig.json
{
"compilerOptions": {
"module": "esnext",
"target": "es5",
"noImplicitAny": true,
"preserveConstEnums": true,
"outDir": "./dist",
"sourceMap": true,
"esModuleInterop": true,
"baseUrl": "../",
"moduleResolution": "node"
},
"include": ["./src/**/*"],
"exclude": ["test", "**/*/spec.ts", "**/*/test.ts"]
}
我的 jest.config.js
module.exports = {
preset: 'ts-jest',
roots: ['src'],
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
};
解决方案
推荐阅读
- google-bigquery - 大查询 - Adwords - AuthenticationError.NOT_ADS_USER
- javascript - 如何遍历文本文件中的一系列地址并获取 Node.js 中的各个字段
- firebase - Firebase变量的iOS推送通知?可能的?
- python - Pandas 在连续组中替换除第一个以外的所有内容
- c# - 具有多个数据库的 .Net Core 应用程序中的 DBContext 架构(每个客户端 1 个)
- java - 使用类注解在 Spring AOP 的类初始化上运行
- c# - 为什么 XamlWriter 会在某些属性中添加 {}?
- javascript - 是否可以仅通过少量导出“导入为”?
- remote-access - 你如何将你的漏洞粘贴/发送/传递到远程主机?
- python - problem with command heroku run -a
pipenv run upgrade