No env variables found with turbo v2.0.4 with t3-app

Everytime it builds it gives these errors:
web:build: $ next build
web:build: :x: Invalid environment variables: {
web:build: NEXTAUTH_SECRET: [ 'Required' ],
web:build: NEXTAUTH_URL: [ 'Invalid url' ],
web:build: AWS_ACCESS_KEY_ID: [ 'Required' ],
web:build: AWS_SECRET_ACCESS_KEY: [ 'Required' ],
web:build: AWS_REGION: [ 'Required' ],
web:build: AWS_ENDPOINT: [ 'Required' ],
web:build: GOOGLE_CLIENT_ID: [ 'Required' ],
web:build: GOOGLE_CLIENT_SECRET: [ 'Required' ],
web:build: DISCORD_CLIENT_ID: [ 'Required' ],
web:build: DISCORD_CLIENT_SECRET: [ 'Required' ]
web:build: }
web:build: ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
web:build:
web:build: $ next build
web:build: :x: Invalid environment variables: {
web:build: NEXTAUTH_SECRET: [ 'Required' ],
web:build: NEXTAUTH_URL: [ 'Invalid url' ],
web:build: AWS_ACCESS_KEY_ID: [ 'Required' ],
web:build: AWS_SECRET_ACCESS_KEY: [ 'Required' ],
web:build: AWS_REGION: [ 'Required' ],
web:build: AWS_ENDPOINT: [ 'Required' ],
web:build: GOOGLE_CLIENT_ID: [ 'Required' ],
web:build: GOOGLE_CLIENT_SECRET: [ 'Required' ],
web:build: DISCORD_CLIENT_ID: [ 'Required' ],
web:build: DISCORD_CLIENT_SECRET: [ 'Required' ]
web:build: }
web:build: ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
web:build:
I have tried loose mode but the error remains, i know this issue is cause of turbo cause when i downgrade the package to around 1.11.3 it works again.
Solution:
adding it to the start script as well fixed it
Jump to solution
5 Replies
Jeremy
JeremyOP6mo ago
for a little more context look at my repo https://github.com/outfits-bio/app/tree/app-refactor, make sure you're on the app-refactor branch and keep in mind i downgraded back to turbo 1.11.3 on this code just for it to work but i'd like to use the new turbo version since it seperates my stuff, also hoping its faster This was the code when the error was happening: https://github.com/outfits-bio/app/tree/fe4a58f57365b30f70f85fb5c2afdb517636003c Feel free to ping me if you have any idea
Matvey
Matvey6mo ago
In turbo.json add env: ["*"] option to the task
{
"tasks": {
"build": {
"env": ["*"]
}
}
{
"tasks": {
"build": {
"env": ["*"]
}
}
Jeremy
JeremyOP6mo ago
will try
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": [
"**/.env.*local"
],
"tasks": {
"db:push": {
"cache": false
},
"lint": {},
"dev": {
"cache": false,
"persistent": true,
"dependsOn": [
"^db:generate"
]
},
"build": {
"env": ["*"],
"dependsOn": [
"^build",
"^db:generate"
],
"outputs": [
".next/**",
"!.next/cache/**"
]
},
"start": {
"dependsOn": [
"^start",
"^build",
"^db:generate"
]
},
"db:generate": {
"cache": false
}
}
}
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": [
"**/.env.*local"
],
"tasks": {
"db:push": {
"cache": false
},
"lint": {},
"dev": {
"cache": false,
"persistent": true,
"dependsOn": [
"^db:generate"
]
},
"build": {
"env": ["*"],
"dependsOn": [
"^build",
"^db:generate"
],
"outputs": [
".next/**",
"!.next/cache/**"
]
},
"start": {
"dependsOn": [
"^start",
"^build",
"^db:generate"
]
},
"db:generate": {
"cache": false
}
}
}
this is my new turbo.json ill push to prod rq, is there any things in here i do not need with the new version
database:db:generate: └─────────────────────────────────────────────────────────────┘
database:db:generate:
web:start: cache miss, executing 05043452f568280d
web:start: $ next start
web:start: ▲ Next.js 14.2.4
web:start: - Local: http://localhost:3000
web:start:
web:start: ✓ Starting...
web:start: ❌ Invalid environment variables: {
web:start: NEXTAUTH_SECRET: [ 'Required' ],
web:start: NEXTAUTH_URL: [ 'Required' ],
web:start: AWS_ACCESS_KEY_ID: [ 'Required' ],
web:start: AWS_SECRET_ACCESS_KEY: [ 'Required' ],
web:start: AWS_REGION: [ 'Required' ],
web:start: AWS_ENDPOINT: [ 'Required' ],
web:start: GOOGLE_CLIENT_ID: [ 'Required' ],
web:start: GOOGLE_CLIENT_SECRET: [ 'Required' ],
web:start: DISCORD_CLIENT_ID: [ 'Required' ],
web:start: DISCORD_CLIENT_SECRET: [ 'Required' ]
web:start: }
web:start: ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
web:start: Error: Invalid environment variables
web:start: at onValidationError (file:///app/node_modules/@t3-oss/env-core/dist/index.js:29:15)
web:start: at createEnv (file:///app/node_modules/@t3-oss/env-core/dist/index.js:35:16)
web:start: at createEnv (file:///app/node_modules/@t3-oss/env-nextjs/dist/index.js:12:12)
web:start: at file:///app/apps/web/src/env.js:4:20
web:start: at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
web:start: at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
web:start: at async file:///app/apps/web/next.config.js:11:1
web:start: error: script "start" exited with code 1
web:start: ERROR: command finished with error: command (/app/apps/web) /root/.nix-profile/bin/bun run start exited (1)
web#start: command (/app/apps/web) /root/.nix-profile/bin/bun run start exited (1)

Tasks: 1 successful, 2 total
Cached: 0 cached, 2 total
Time: 3.474s
Failed: web#start
database:db:generate: └─────────────────────────────────────────────────────────────┘
database:db:generate:
web:start: cache miss, executing 05043452f568280d
web:start: $ next start
web:start: ▲ Next.js 14.2.4
web:start: - Local: http://localhost:3000
web:start:
web:start: ✓ Starting...
web:start: ❌ Invalid environment variables: {
web:start: NEXTAUTH_SECRET: [ 'Required' ],
web:start: NEXTAUTH_URL: [ 'Required' ],
web:start: AWS_ACCESS_KEY_ID: [ 'Required' ],
web:start: AWS_SECRET_ACCESS_KEY: [ 'Required' ],
web:start: AWS_REGION: [ 'Required' ],
web:start: AWS_ENDPOINT: [ 'Required' ],
web:start: GOOGLE_CLIENT_ID: [ 'Required' ],
web:start: GOOGLE_CLIENT_SECRET: [ 'Required' ],
web:start: DISCORD_CLIENT_ID: [ 'Required' ],
web:start: DISCORD_CLIENT_SECRET: [ 'Required' ]
web:start: }
web:start: ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
web:start: Error: Invalid environment variables
web:start: at onValidationError (file:///app/node_modules/@t3-oss/env-core/dist/index.js:29:15)
web:start: at createEnv (file:///app/node_modules/@t3-oss/env-core/dist/index.js:35:16)
web:start: at createEnv (file:///app/node_modules/@t3-oss/env-nextjs/dist/index.js:12:12)
web:start: at file:///app/apps/web/src/env.js:4:20
web:start: at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
web:start: at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
web:start: at async file:///app/apps/web/next.config.js:11:1
web:start: error: script "start" exited with code 1
web:start: ERROR: command finished with error: command (/app/apps/web) /root/.nix-profile/bin/bun run start exited (1)
web#start: command (/app/apps/web) /root/.nix-profile/bin/bun run start exited (1)

Tasks: 1 successful, 2 total
Cached: 0 cached, 2 total
Time: 3.474s
Failed: web#start
my error remains
Solution
Jeremy
Jeremy6mo ago
adding it to the start script as well fixed it
Jeremy
JeremyOP6mo ago
thank you very much!
Want results from more Discord servers?
Add your server