Title: Unable to import subpath exports with @t3-oss/env-core in Turborepo monorepo #10803
Unanswered
Hariharan10202
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi, I’m using @t3-oss/env-core inside a Turborepo monorepo with multiple workspaces.
I have a package @workspace/env with the following package.json exports setup:
{
"name": "@workspace/env",
"type": "module",
"main": "./dist/server.js",
"types": "./dist/server.d.ts",
"exports": {
".": {
"types": "./dist/server.d.ts",
"default": "./dist/server.js"
},
"./client": {
"types": "./dist/client.d.ts",
"default": "./dist/client.js"
},
"./server": {
"types": "./dist/server.d.ts",
"default": "./dist/server.js"
}
}
}
{
"name": "@workspace/env",
"type": "module",
"main": "./dist/env.js",
"exports": {
".": {
"types": "./dist/env.d.ts",
"require": "./dist/env.js",
"default": "./dist/env.js"
}
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch"
},
"dependencies": {
"@t3-oss/env-core": "^0.13.8",
"zod": "^3.25.76",
"@workspace/typescript-config": "workspace:*"
}
}
When I try to import it from another workspace like:
import { env } from "@workspace/env/server";I get an error in TypeScript:
Cannot find module '@workspace/env/server' or its corresponding type declarations.However, import { env } from "@workspace/env" works fine.
What I’ve tried:
Ensured dist/server.js and dist/server.d.ts exist after build.
Checked exports paths match the dist folder structure.
Tried clearing node_modules and rebuilding.
Tried with moduleResolution: bundler and node16 in tsconfig.
How do I import both in client and server ?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions