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
We have a TypeScript project. To run this project in production, we first build it, then execute it with node.
For the build, we use plain tsc (no Babel) because it is a simple backend service intended to run on Node.js.
Until now, we enjoyed absolute imports through NODE_PATH. The idea is simple:
TypeScript compiler knows about absolute imports. However, tsc does not translate absolute imports to relative in generated js files, it leaves them as absolute.
However, with Yarn PNP NODE_PATH is not passed to node and absolute imports no longer work. We simply cannot start the service in production anymore after migrating to PNP.
This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).
Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃
If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟
Self-service
Describe the bug
We have a TypeScript project. To run this project in production, we first build it, then execute it with
node
.For the build, we use plain
tsc
(no Babel) because it is a simple backend service intended to run on Node.js.Until now, we enjoyed absolute imports through
NODE_PATH
. The idea is simple:tsc
does not translate absolute imports to relative in generatedjs
files, it leaves them as absolute.src
, build goes tobuild
.So far, we ran the service in production with:
This worked great so far.
However, with Yarn PNP
NODE_PATH
is not passed tonode
and absolute imports no longer work. We simply cannot start the service in production anymore after migrating to PNP.Someone suggested to take a look at
link:
which is described here: https://yarnpkg.com/features/protocols#why-is-the-link-protocol-recommended-over-aliases-for-path-mapping. However, that works only for plain JavaScript workspaces. Linkingsrc
makes no sense since our build goes tobuild
,src
only contains TypeScript and we have no issues with compiling.To reproduce
baseUrl
setting.tsc
. Sotsconfig.json
looks like this:Which is very standard for TS.
Environment
Additional context
I believe the fix is simple:
yarn
should pass existingNODE_PATH
to node (it can append whatever it needs)The text was updated successfully, but these errors were encountered: