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
Possible regression with ts-node 10.0.0: ts extension not registered? #1368
For this codebase, running make tests (essentially, npx mocha) runs unit tests over some TypeScript code, and completes successfully. The codebase has ts-node configured matching semver ^9.1.1.
After upgrading the package.jsonts-node entry to 10.0.0 in package.json file, and running npm install --also=dev, unit tests should continue to pass.
Actual Behavior
After the upgrade, unit tests fail:
TS_NODE_IGNORE='node_modules/(?!document-prev)' npx mocha
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/jka/Documents/reciperadar/document/src/index.spec.ts
at new NodeError (node:internal/errors:363:5)
at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
at Loader.getFormat (node:internal/modules/esm/loader:105:42)
at Loader.getModuleJob (node:internal/modules/esm/loader:243:31)
at Loader.import (node:internal/modules/esm/loader:177:17)
at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
at formattedImport (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/esm-utils.js:7:14)
at Object.exports.loadFilesAsync (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/esm-utils.js:55:20)
at singleRun (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/cli/run-helpers.js:125:3)
at Object.exports.handler (/home/jka/Documents/reciperadar/document/node_modules/mocha/lib/cli/run.js:362:5)
make: *** [Makefile:9: tests] Error 1
Steps to reproduce the problem
Update the devDependency entry for ts-node, reinstall dependencies (including dev), and then run make tests.
Minimal reproduction
I'll attempt to narrow this down and fill in the minimal repro case soon.
Not a regression, it's an improvement in our behavior to more closely align with nodejs, which is forcing you to use our ESM loader when your project uses "type": "module".
I believe that covers all the bases. If you need anything else, I recommend either the TypeScript Community Discord or our discussion forum. Both are linked from the navigation bar of our website: https://typestrong.org/ts-node
Activity
cspotcode commentedon Jun 6, 2021
Not a regression, it's an improvement in our behavior to more closely align with nodejs, which is forcing you to use our ESM loader when your project uses
"type": "module".Here is the relevant changelog entry:
See also: #1342 which is pending feedback from some other open-source maintainers.
Solutions for you in the short-term. You will have to decide which of these are viable:
"type": "module")ts-nodev9.1.1 until Flag for ESM loader to override package.json "type" #1342 or some equivalent feature is releasedI believe that covers all the bases. If you need anything else, I recommend either the TypeScript Community Discord or our discussion forum. Both are linked from the navigation bar of our website: https://typestrong.org/ts-node
jayaddison commentedon Jun 6, 2021
Thanks @cspotcode - and my apologies, I did read the changelog but I didn't catch that entry somehow. I think we can close this.