You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use explicit extensions in TypeScript's package.json for Node ES resolution compatibilityΒ #44342
And when I call yarn tsc, nodejs trying to run node_modules/typescript/bin/tsc. This file hasn't extension and nodejs throws an error.
Why it works in Jest?
Because it use another bin declaration like this:
{
"jest": "./bin/jest.js"
}
For package manager, this script has link with name jest, but nodejs run jest.js, file with extension.
So, solving my problem is adding .js in bin files and in paths in package.json bin. It won't change behavior for exists project by help projects with configurations like mine.
As you can see, another experimental flags for native modules aren't change behavior (Now I run tsc without --experimental-specifier-resolution, but with all another flags in scripts and it works)
changed the title [-]Support node es modules resolution[/-][+]Use explicit extensions in TypeScript's package.json for Node ES resolution compatibility[/+]on Jun 1, 2021
Activity
dansaper commentedon May 31, 2021
I assume this is related to https://gist.github.com/weswigham/22a064ffa961d5921077132ae2f8da78?
tsapko3628 commentedon May 31, 2021
Not, it's not.
This problem because of bin script definition.
Bin scripts defined as
{ "tsc": "./bin/tsc.js", "tsserver": "./bin/tsserver" }And when I call
yarn tsc, nodejs trying to runnode_modules/typescript/bin/tsc. This file hasn't extension and nodejs throws an error.Why it works in Jest?
Because it use another
bindeclaration like this:{ "jest": "./bin/jest.js" }For package manager, this script has link with name jest, but nodejs run jest.js, file with extension.
So, solving my problem is adding
.jsin bin files and in paths inpackage.jsonbin. It won't change behavior for exists project by help projects with configurations like mine.As you can see, another experimental flags for native modules aren't change behavior (Now I run tsc without
--experimental-specifier-resolution, but with all another flags in scripts and it works)tsapko3628 commentedon Jun 1, 2021
I created pull request with resolution. Can somebody approve it?
[-]Support node es modules resolution[/-][+]Use explicit extensions in TypeScript's package.json for Node ES resolution compatibility[/+]