Code Monkey home page Code Monkey logo

Comments (6)

TarSzator avatar TarSzator commented on June 11, 2024 7

@jahirvidrio The issue is not that I see an error. The issue is that I not see it when I use Node v20.

Meaning that I do not see a proper error message when I use Node v20

from ts-node.

TarSzator avatar TarSzator commented on June 11, 2024 4

I feel my issue fits into this.

ts-node v10.9.1

When I have simple code like

import http from 'http';

And I run it via

node --loader ts-node/esm bin/test.ts

in Node 20. I get the output

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^
[Object: null prototype] {
  [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}

Node.js v20.9.0

When I execute it in Node 18.18.2 I get the output

/[...]/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
bin/test.ts:1:1 - error TS6133: 'http' is declared but its value is never read.

1 import http from 'http';
  ~~~~~~~~~~~~~~~~~~~~~~~~

    at createTSError
    [...]

This is of corse an academic example but also applies for way more complex projects

I tried multiple ways of executing node with ts-node all yield the same result.

from ts-node.

davidthornton avatar davidthornton commented on June 11, 2024 4

Hello TypeScript team!

I appear to also be experiencing this with my loader command:

api-1  | > node --no-warnings --watch --loader ts-node/esm index.ts
api-1  | 
api-1  | 
api-1  | node:internal/process/esm_loader:40
api-1  |       internalBinding('errors').triggerUncaughtException(
api-1  |                                 ^
api-1  | [Object: null prototype] {
api-1  |   [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
api-1  | }
api-1  | 
api-1  | Node.js v18.19.0
api-1  | Failed running 'index.ts'

Any help would be appreciated!

from ts-node.

cj-christoph-gysin avatar cj-christoph-gysin commented on June 11, 2024 1

I'm seeing the same issue as @TarSzator. It seems the problem now also exists in node-18.19.0:

$ node --version
v18.18.2
$ NODE_OPTIONS="--no-warnings=ExperimentalWarning --experimental-loader=ts-node/esm" npx ts-node main.ts
/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
main.ts:1:7 - error TS2322: Type 'string' is not assignable to type 'number'.
$ node --version
v18.19.0
$ NODE_OPTIONS="--no-warnings=ExperimentalWarning --experimental-loader=ts-node/esm" npx ts-node main.ts
[Object: null prototype] {
  [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}
$ node --version
v20.10.0
$ NODE_OPTIONS="--no-warnings=ExperimentalWarning --experimental-loader=ts-node/esm" npx ts-node main.ts
[Object: null prototype] {
  [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}

from ts-node.

jahirvidrio avatar jahirvidrio commented on June 11, 2024

@TarSzator Your issue is not actually an error; it's a configuration in your tsconfig.json file that instructs the compiler to throw an error when a variable is not used. Simply modify the compilerOptions.noUnusedLocals and compilerOptions.noUnusedParameters properties to false.

from ts-node.

davidthornton avatar davidthornton commented on June 11, 2024

Apologies, team I misinterpreted @cj-christoph-gysin's answer as a confirmation that (all) node 18 minor versions worked and that it was just node 20 -- but didn't know I could simply downgrade from my existing 18.19.0 Docker image to the 18.18.2 image build... Which I can now happily confirm a second time - works!

I'm not terribly familiar with node/ts/es6 internals but does that mean it's a problem with the ts-node loader, or could it still be a weird minor version node runtime change?

from ts-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.