Compilation errors on GitHub workflow during tsc while no errors locally

21 views Asked by At

2 days ago I rolled out a node.js service via GitHub workflow without errors. After adding just one tiny test and increasing the version the github workflow triggered compilation errors today.

The task where the workflow fails is:

tsc --noEmit --noErrorTruncation --pretty --resolveJsonModule -p tsconfig.json

Found 10 errors in 3 files.

Errors  Files
     1  src/routes/__test__/signout.test.ts:21
     1  src/routes/__test__/signup.test.ts:151
     8  src/routes/__test__/update.test.ts:94
Error: Process completed with exit code 2.

whereas running the same 'npm run check' locally, there are no errors.

Environments:

GitHub:
  node: v20.11.1 
  npm: 10.2.4
  yarn: 1.22.22

(The screenshot below shows version 16, where the error occurred first. Then I updated, but still the same outcome)

Local (WSL2):
  node: v20.11.1
  npm: 10.5.0

The referenced tsconfig.json:

{
    "compilerOptions": {
        "target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
        "module": "commonjs" /* Specify what module code is generated. */,
        "noEmit": true /* Disable emitting files from a compilation. */,
        "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
        "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
        "strict": true /* Enable all strict type-checking options. */,
        "skipLibCheck": true /* Skip type checking all .d.ts files. */
    },
    "include": ["src", "global.d.ts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
    "exclude": [
        "node_modules",
        "./node_modules",
        "./node_modules/*",
        "./node_modules/@types/node/index.d.ts",
        "node_modules/**",
        "plugins",
        "public"
    ]
}

The particular crazy thing about these errors is that I use

.set('Cookie', cookie)

literally hundreds of times in countless tests, yet the tsc compilation error on GitHub only lists 10 errors. Should it not list all *.test.ts files?

What could make the compilation fail all the sudden versus not failing 2 days ago?

Please advise with methods of how to approach this situation.

2 days ago: Unit tests running without errors

Today: Unit tests running with exactly 10 compilation errors

1

There are 1 answers

0
ShadowGames On

Turned out, I had to remove my node_modules folder and rerun npm install

After that I could reproduce the same TS errors with npm run check.

Also: Duplicate to TSC build errors during github-action but compiles fine locally