Skip to content

Source maps broken under Windows since 8.10.0 (ESM support) #1037

@shunf4

Description

@shunf4

Expected Behavior

Source maps work under Windows 10 in 8.10.0 and later versions.

Actual Behavior

Source maps are broken under Windows 10 since 8.10.0 (ESM support). Under GNU/Linux it works well.

Steps to reproduce the problem

test.ts:

function main() {






  throw new Error("aaa")
  console.log(1)
  console.log(1)
  console.log(1)
  console.log(1)
  console.log(1)
  console.log(1)
}

main()

Running ts-node test.ts should always give output like this:

  throw new Error("aaa")
        ^
Error: aaa
    at main (C:\Users\User\Desktop\test.ts:8:9)
    at Object.<anonymous> (C:\Users\User\Desktop\test.ts:17:1)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Module.m._compile (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:839:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:842:12)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at main (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\bin.ts:227:14)

When running under Windows 10, ts-node 8.10.0 and later give:

Error: aaa
    at main (C:\Users\User\Desktop\test.ts:2:11)
    at Object.<anonymous> (C:\Users\User\Desktop\test.ts:10:1)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Module.m._compile (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:858:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:861:12)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at main (C:\Users\User\AppData\Roaming\npm\node_modules\ts-node\src\bin.ts:227:14)

The line number do not correspond to the .ts file. The source map is broken.

Minimal reproduction

See "Steps to reproduce the problem".

Specifications

  • ts-node version: v8.10.0 and later
  • node version: v12.13.0 and v14.2.0
  • TypeScript version: v3.8.3
  • tsconfig.json, if you're using one: None
  • Operating system and version: Windows 10 Version 1909 (OS Build 18363.752)
  • If Windows, are you using WSL or WSL2?: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions