I have a TypeScript project, based on Node.js, with several modules (using workspaces). Everything executes correctly, but I’m still receiving warnings. In particular, when running this (as a package.json
‘script’ in Yarn)
ts-node --project path/tsconfig.json path/script.ts <args-to-script>
I’m seeing two classes of warnings:
- In Visual Studio Code, squiggly underlines in the imports of
makefont.ts
, because I (have to) specify.ts
file extensions; - At the command-prompt, warning messages on execution, stating that “ExperimentalWarning: Type Stripping is an experimental feature and might change at any time”
I think the two warnings are related. I’m using NodeJS 23.7.0, Yarn 1.22.22, ts-node 10.9.2, TypeScript 5.5.4
Imports with file extensions:
Without the .ts
, I get “Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/andrew/projects/retrofabulationzx/app/node_modules/fonts/font1' imported from /Users/andrew/projects/retrofabulationzx/app/rom/build/makefont.ts
”
Note that, additionally, I’ve had to split off a type import (Glyph
) into a separate import
statement. I suspect that both of these issues are related to the ‘Type Stripping’ mentioned below:
ExperimentalWarning
It seems that ts-node is using the (experimental) Node Type Stripping feature to run TypeScript… I am sure that it wasn’t doing this previously, before I implemented workspaces…
Does ts-node have problems running within a Yarn/NPM ‘workspace’?
What the project looks like:
fonts/
(workspace)font1.ts
package.json
tsconfig.json
rom/
(workspace)build/
makefont.ts
tsconfig.json
generated/
(output directory)package.json
package.json
tsconfig.json
/package.json
{
"private": true,
"workspaces": [
"fonts",
"rom",
],
"devDependencies": {
"@jest/globals": "^29.1.2",
"@types/node": "^22.4.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
},
"packageManager": "[email protected]"
}
/tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "ES6",
"outDir": "dist",
"esModuleInterop": true,
"moduleResolution": "node"
},
"include": [],
"exclude": [ "**/node_modules" ],
}
fonts/package.json
{
"name": "fonts",
"version": "1.0.0",
"type": "module"
}
fonts/tsconfig.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true
},
"include": [ "./*.ts" ]
}
rom/package.json
{
"name": "rom",
"version": "1.0.0",
"type": "module",
"devDependencies": {
"@types/node": "^22.4.0",
"fonts": "1.0.0",
"ts-node": "^10.9.2",
"typescript": "^5.5.4",
"zxsys": "1.0.0"
},
"scripts": {
"genfont": "ts-node --project build/tsconfig.json build/makefont.ts generated/font.z80",
// plus others
}
}
rom/build/tsconfig.json
{
"extends": "../../tsconfig.json",
"ts-node": {
"esm": true
},
"compilerOptions": {
},
"references": [
{ "path": "../../fonts" },
// +others
],
"include": [ "./*.ts" ],
}
Exact command-line invocation
yarn workspace rom genfont