valibot: cant parse process.env
Hello,
I try to parse my .env file but it gives me an error. I am using dotenv and next.js (dev with turbopack)
env.ts
import "dotenv/config";
import {object, parse, string} from "valibot";
const envVariables = object({
FIREBASE_API_KEY: string(),
FIREBASE_AUTH_DOMAIN: string(),
FIREBASE_PROJECT_ID: string(),
FIREBASE_STORAGE_BUCKET: string(),
FIREBASE_MESSAGING_SENDER_ID: string(),
FIREBASE_APP_ID: string(),
});
const env = parse(envVariables, process.env);
export default env;
.env
FIREBASE_API_KEY=...
FIREBASE_AUTH_DOMAIN=...
FIREBASE_PROJECT_ID=...
FIREBASE_STORAGE_BUCKET=...
FIREBASE_MESSAGING_SENDER_ID=...
FIREBASE_APP_ID=...
error
Call Stack
Module.parse
/turbopack/[project]/node_modules/.pnpm/valibot@0.13.1/node_modules/valibot/dist/index.js (3130:11)
<unknown>
/turbopack/[project]/src/env.ts (13:13)
[project]/src/env.ts (ecmascript)
/_next/static/chunks/src_env_ts_27ce24._.js (25:3)
<unknown>
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (394:27)
runModuleExecutionHooks
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (427:9)
instantiateModule
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (393:9)
getOrInstantiateModuleFromParent
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (454:12)
esmImport
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (102:20)
<unknown>
/_next/static/chunks/src_firebase_56d9e3._.js (9:94)
[project]/src/firebase/firebase.ts (ecmascript)
/_next/static/chunks/src_firebase_56d9e3._.js (27:3)
<unknown>
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (394:27)
runModuleExecutionHooks
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (427:9)
instantiateModule
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (393:9)
getOrInstantiateModuleFromParent
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (454:12)
esmImport
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (102:20)
<unknown>
/_next/static/chunks/src_manager_UserManager_ts_749c94._.js (16:111)
[project]/src/manager/UserManager.ts (ecmascript)
/_next/static/chunks/src_manager_UserManager_ts_749c94._.js (122:3)
<unknown>
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (394:27)
runModuleExecutionHooks
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (427:9)
instantiateModule
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (393:9)
getOrInstantiateModuleFromParent
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (454:12)
esmImport
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (102:20)
<unknown>
/_next/static/chunks/src_components_LoginForm_tsx_33c65e._.js (367:113)
[project]/src/components/LoginForm.tsx (ecmascript)
/_next/static/chunks/src_components_LoginForm_tsx_33c65e._.js (494:3)
<unknown>
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (394:27)
runModuleExecutionHooks
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (427:9)
instantiateModule
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (393:9)
getOrInstantiateModuleFromParent
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (454:12)
esmImport
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (102:20)
<unknown>
/_next/static/chunks/src_app_login_page_tsx_b53fce._.js (9:115)
[project]/src/app/login/page.tsx (ecmascript)
/_next/static/chunks/src_app_login_page_tsx_b53fce._.js (40:3)
<unknown>
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (394:27)
runModuleExecutionHooks
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (427:9)
instantiateModule
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (393:9)
getOrInstantiateModuleFromParent
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (454:12)
commonJsRequire
/_next/static/chunks/[next]_entry_app_hydrate_tsx_f5eb0c._.js (109:20)
globalThis.__next_require__
/turbopack/[next]/entry/app/hydrate.tsx (24:10)
requireAsyncModule
/turbopack/[project]/node_modules/.pnpm/next@13.4.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (75:28)
<unknown>
/turbopack/[project]/node_modules/.pnpm/next@13.4.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js (129:16)```
</details>
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 17 (8 by maintainers)
Okay, thanks for your help tho.