Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSError: ⨯ Unable to compile TypeScript after version 10.1.0 #23087

Closed
dobladov opened this issue Aug 3, 2022 · 3 comments
Closed

TSError: ⨯ Unable to compile TypeScript after version 10.1.0 #23087

dobladov opened this issue Aug 3, 2022 · 3 comments

Comments

@dobladov
Copy link

dobladov commented Aug 3, 2022

Current behavior

After upgrading from version 10.0.3 to 10.1.0 cypress shows this error.
The typescript file seems to be ignored, the project works fine with the previous.
Upgrading to any newer version than 10.1.0 does not fix it, I tried with 10.4.0 too.

The error:

> TS_NODE_PROJECT=0 cypress run

(node:94304) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:94304) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:820
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS5083: Cannot read file '/Users/username/code/project/0'.

    at createTSError (/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:820:12)
    at reportTSError (/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:824:19)
    at createFromPreloadedConfig (/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:835:36)
    at create (/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:597:10)
    at register (/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:564:15)
    at Object.registerAndCreateEsmHooks (/Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/esm.ts:126:34)
    at file:///Users/username/Library/Caches/Cypress/10.4.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/esm/transpile-only.mjs:8:7
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24) {
  diagnosticCodes: [ 5083 ]
}

cypress/tsconfig.json

{
    "compilerOptions": {
        "baseUrl": "../app",
        "types": [],
        "moduleResolution": "node",
        "target": "esnext",
        "module": "esnext",
        "noEmit": true,
        "allowJs": true,
        "checkJs": true,
        "jsx": "preserve",
        "experimentalDecorators": true,
        "preserveSymlinks": true,
        "strict": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "strictNullChecks": false,
        "suppressImplicitAnyIndexErrors": true,
        "allowSyntheticDefaultImports": true,
        "resolveJsonModule": true,
        "paths": {
            "@shop/*": ["../app/*"],
            "@e2e/*": ["../cypress/*"],
        },
        "types": [
            "cypress",
        ],
        "skipLibCheck": true,
    },
    "include": [
        "./**/*",
    ]
}

Desired behavior

Cypress runs as it did with the previous version, without any typescript compilation errors.

Test code to reproduce

Unfortunately, it's a private repository.

Cypress Version

10.1.0

Other

The only relevant change that I see in the changelog for this to fail is, but I could not find a solution.

Added support for TypeScript projects using "type": "module" using ts-node/esm. Fixed #22096, #21939, and #22074

@dobladov
Copy link
Author

dobladov commented Aug 3, 2022

Cypress was running with TS_NODE_PROJECT=0 removing it fixes the problem.

@dobladov dobladov closed this as completed Aug 3, 2022
@coler-j
Copy link

coler-j commented Aug 5, 2022

@dobladov where is it running with that and how do you remove it?

@dobladov
Copy link
Author

dobladov commented Aug 5, 2022

@coler-j it was running locally with this command in pacakge.json

"test:e2e": "TS_NODE_PROJECT=0 cypress open",

After removing the env variable TS_NODE_PROJECT=0 , it works fine using newer versions than 10.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants