I fail to transpile my typescript files in AWS CodeBuild (Ubuntu image) with TS2307 error failing to resolve my own files.
Of course, I tried the exact same project locally. Invoking tsc which is reading my tsconfig.json file in the root of the project directory. Then I would run node ./dist/index.js to execute the app with node (and not ts-node ./src/index.ts). Works (the REST services provide json data).
In AWS CodeBuild the tsc fails.
These are my code lines which fail to be resolve relatively. Before there are absolute imports (e.g. import * as express from 'express') which all work fine.
Does someone have any clue why that does not resolve/transpile in AWS CodeBuild despite it is the same project files (all after a pull from github)? What flag am I missing?
I'm using Windows locally. And Ubuntu in CodeBuild.
import { TermEndpoints } from './endpoints/termEndpoints'
import { TranslationEndpoints } from './endpoints/translationEndpoints'
import { LanguageEndpoints } from './endpoints/LanguageEndpoints'
import { NavLangEndpoints} from './endpoints/navLangEndpoints'
import { InfoEndpoint } from './endpoints/infoEndpoint'
My tsconfig.json file is
{
"compilerOptions": {
"baseUrl": "./src/",
"outDir": "./dist",
"allowJs": true,
"target": "es2017",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": false,
"strict": false,
"declaration": true,
"experimentalDecorators": true,
"importHelpers": true,
"esModuleInterop": false,
"resolveJsonModule": true,
"removeComments": true,
"types": ["node"],
"typeRoots": [
"node_modules/@types"
],
"lib": [ "es2017", "dom" ]
},
"include": [
"./src/**/*"
]
}
Log file from Code Build
[Container] 2020/05/11 10:06:10 Running command npm install typescript
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ typescript@3.8.3
updated 1 package and audited 655 packages in 2.484s
found 0 vulnerabilities
[Container] 2020/05/11 10:06:13 Running command tsc --version
Version 3.8.3
[Container] 2020/05/11 10:06:13 Running command npm run build:acc
> sem-translator-api@0.0.1 build:acc /codebuild/output/src400516343/src/github.com/svabra/semtranslatorapi
> tsc
src/ExpressServer.ts(11,31): error TS2307: Cannot find module './endpoints/termEndpoints'.
src/ExpressServer.ts(12,38): error TS2307: Cannot find module './endpoints/translationEndpoints'.
src/ExpressServer.ts(13,35): error TS2307: Cannot find module './endpoints/LanguageEndpoints'.
src/models/relation.ts(3,22): error TS2307: Cannot find module './Term'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! sem-translator-api@0.0.1 build:acc: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the sem-translator-api@0.0.1 build:acc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-11T10_06_18_948Z-debug.log
[Container] 2020/05/11 10:06:18 Command did not exit successfully npm run build:acc exit status 2
[Container] 2020/05/11 10:06:19 Phase complete: BUILD State: FAILED
[Container] 2020/05/11 10:06:19 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run build:acc. Reason: exit status 2