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

Local plugin "Unable to compile TypeScript" error with ts-node (without swc) #15038

Closed
forivall opened this issue Feb 16, 2023 · 4 comments · Fixed by #15066
Closed

Local plugin "Unable to compile TypeScript" error with ts-node (without swc) #15038

forivall opened this issue Feb 16, 2023 · 4 comments · Fixed by #15066

Comments

@forivall
Copy link
Contributor

forivall commented Feb 16, 2023

Current Behavior

While #9823 is solved (by #14995), in my workspace without swc and relying on ts-node instead, I'm getting a new error (see below Failure Logs)

Expected Behavior

The executor should successfully run, as it does when swc is installed:

» nx run demo:build

> nx run demo:build

Executor ran for Build {}

 —————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for project demo (378ms)

GitHub Repo

https://github.com/forivall/nx-repro-local-plugin-issue/tree/without-swc

Steps to Reproduce

  1. npm install
  2. npx nx run demo:build --verbose

Nx Report

Node : 16.17.0
OS   : darwin arm64
npm  : 8.15.0

nx                      : 15.7.1
@nrwl/jest              : 15.7.1
@nrwl/linter            : 15.7.1
@nrwl/workspace         : 15.7.1
@nrwl/cli               : 15.7.1
@nrwl/devkit            : 15.7.1
@nrwl/eslint-plugin-nx  : 15.7.1
@nrwl/js                : 15.7.1
@nrwl/nx-plugin         : 15.7.1
@nrwl/tao               : 15.7.1
typescript              : 4.8.4
---------------------------------------
Local workspace plugins:
 @repro-local-plugin-issue/repro

Failure Logs

» nx run demo:build --verbose

> nx run demo:build

 >  NX   ⨯ Unable to compile TypeScript:
   error TS5024: Compiler option 'module' requires a value of type string.
   error TS5024: Compiler option 'target' requires a value of type string.

TSError: ⨯ Unable to compile TypeScript:
error TS5024: Compiler option 'module' requires a value of type string.
error TS5024: Compiler option 'target' requires a value of type string.
    at createTSError (/Users/emily.klassen/code/sandbox/repro-local-plugin-issue/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/emily.klassen/code/sandbox/repro-local-plugin-issue/node_modules/ts-node/src/index.ts:863:19)
    at createFromPreloadedConfig (/Users/emily.klassen/code/sandbox/repro-local-plugin-issue/node_modules/ts-node/src/index.ts:874:36)
    at create (/Users/emily.klassen/code/sandbox/repro-local-plugin-issue/node_modules/ts-node/src/index.ts:624:10)
    at register (/Users/emily.klassen/code/sandbox/repro-local-plugin-issue/node_modules/ts-node/src/index.ts:591:15)
    at registerTranspiler (/Users/emily.klassen/code/sandbox/packages/nx/src/utils/register.ts:64:25)
    at registerTranspiler (/Users/emily.klassen/code/sandbox/packages/nx/src/utils/register.ts:78:12)
    at registerPluginTSTranspiler (/Users/emily.klassen/code/sandbox/packages/nx/src/utils/nx-plugin.ts:194:23)
    at /Users/emily.klassen/code/sandbox/packages/nx/src/config/workspaces.ts:326:35
    at /Users/emily.klassen/code/sandbox/packages/nx/src/command-line/run.ts:189:28

 ————————————————————————————————————————————————————————————————————————————

 >  NX   Running target build for project demo failed

   Failed tasks:

   - demo:build

   Hint: run the command with --verbose for more details.

Additional Information

No response

@forivall forivall changed the title Local plugin "Unable to compile TypeScript" error without swc Local plugin "Unable to compile TypeScript" error with ts-node (without swc) Feb 16, 2023
@yharaskrik
Copy link
Contributor

Also seeing this across all our custom executors

@yharaskrik
Copy link
Contributor

yharaskrik commented Feb 16, 2023

nx-plugin.ts lines 196,197 are using enum values from TS but those are numbers not strings which are not valid values for the module and target options when registering a TS project.
image
image

Looks like when registering the compiler with ts-node the typing for compilerOptions is object which means that the number/string mismatch will not be caught. The typings as per the typescript package are ModuleKind and ScriptKind for module and target but when actually using that value in ts-node it does not seem to like the fact they are numbers vs strings?

@AgentEnder
Copy link
Member

Yeah, that does seem to be the case. Thanks for the investigation!

@github-actions
Copy link

github-actions bot commented Apr 7, 2023

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants