Repository navigation
Description
Contribution
- I'd be willing to implement this feature (contributing guide)
Describe the user story
node.js supports running a subset of typescript natively, but for reasons they don't allow this feature for files in node_modules.
A caveat is that node wants to support npm workspaces, where local sub packages are required thru node_modules.
To do so they check the real path of the file, and will type strip it if it's not within node_modules.
This works in pnpm workspaces, but breaks in pnpm deploy. This repo demonstrates that behavior.
Read or run repro.sh steps to reproduce.
This difference between workspace and deploy structure
bin/node_modules/lib -> ../../lib
out/node_modules/lib -> .pnpm/lib@file++++lib/node_modules/lib
cause this error in out/index.ts, but not bin/index.ts
Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]: Stripping types is currently unsupported for files under node_modules, for "file:///out/node_modules/.pnpm/lib@file++++lib/node_modules/lib/index.ts"
Describe the solution you'd like
It's not clear if this is a pnpm problem or a node problem. It's at the intersection of both. For what it's worth I think node's wrong to forbid type stripping in node_modules, but I'm willing to accept the constraint to avoid dependencies on amaro, tsx, ts-node ect.
Node's dogma is probably that I should compile before deployment, but
- I want all my dev tools to use typescript source, and getting conditional exports right is hard
- source maps :sad: - tho if tsc supported strip-types I'd live without source maps
- I don't care about the startup perf
I think pnpm could solve this by linking the workspace modules to a location other than <store>/*/node_modules/, tho I think that node_modules is important (but how is the workspace working 🤔 )
node could solve this by removing the constraint, or introducing new markers for "this is in node_modules but I promise I didn't publishing it to npm"
Describe the drawbacks of your solution
For pnpm this solution feels like bending over backward to odd runtime constraints.
Describe alternatives you've considered
My workaround for now is to use --import=amaro/strip. amaro is the lib that implements node type stripping. I could also switch to bun or deno.
Activity
yegorpetrov commentedon May 7, 2026
It's 100% a node problem. pnpm deploy isn't the only legitimate use case. For example, symlinks are not easy (if at all possible) to preserve when you're supposed to zip node modules for deployment and don't have control over the target file system.
And when l have this among dependencies...
... I can't make my-pkg pure TypeScript even though it's not going to be published.
damianobarbati commentedon May 20, 2026
@everett1992 did you find a solution? This is a nodejs problem, and the dumb decision to not strip files in node_modules, forcing authors to always transpile here and there