W
Wasp3w ago
Zuck

Bad Environment Validation

Server ] [nodemon] starting npm run bundle-and-start || exit 1 [ Client ] [ Client ] VITE v7.1.11 ready in 241 ms [ Client ] [ Client ] ➜ Local: http://localhost:4010/ [ Client ] ➜ Network: http://10.0.0.156:4010/ [ Client ] ➜ press h + enter to show help [ Server ] [ Server ] > server@0.0.0 bundle-and-start [ Server ] > npm run bundle && npm run start [ Server ] [ Server ] [ Server ] > server@0.0.0 bundle [ Server ] > tsc --build && rollup --config --silent [ Server ] [ Server ] [ Server ] > server@0.0.0 start [ Server ] > node --enable-source-maps -r dotenv/config bundle/server.js [ Server ] [ Server!] %s [ Server!] ══ Env vars validation failed ══ [ Server!] [ Server!] - Required [ Server!] [ Server!] ════════════════════════════════ [ Server!] /Users/jacobferrari/wasupupdate/my-saas/app/.wasp/out/sdk/wasp/dist/env/validation.js:11 [ Server!] throw new Error('Error parsing environment variables'); [ Server!] ^ [ Server!] [ Server!] [ Server!] Error: Error parsing environment variables [ Server!] at ensureEnvSchema (/Users/jacobferrari/wasupupdate/my-saas/app/.wasp/out/sdk/wasp/dist/env/validation.js:11:15) [ Server!] at <anonymous> (/Users/jacobferrari/wasupupdate/my-saas/app/.wasp/out/sdk/wasp/dist/client/env.js:4:20) [ Server!] at ModuleJob.run (node:internal/modules/esm/module_job:345:25) [ Server!] at async onImport.tracePromise.proto (node:internal/modules/esm/loader:665:26) [ Server!] at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) [ Server!] [ Server!] Node.js v22.20.0 [ Server ] [nodemon] app crashed - waiting for file changes before starting...
7 Replies
kapa.ai
kapa.ai3w ago
Hi @Zuck. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I can see you're experiencing an environment variable validation error in your Wasp application. The error message indicates that a required environment variable is missing, but unfortunately it's not showing which specific variable is causing the issue. Based on the knowledge sources, here are the common required environment variables that might be missing: Required Server Environment Variables According to the deployment documentation, your server needs these environment variables: 1. DATABASE_URL (required) - The PostgreSQL database connection URL 2. WASP_WEB_CLIENT_URL (required) - The URL where your frontend is running 3. WASP_SERVER_URL (required) - The URL where your server is running 4. JWT_SECRET (required if using Wasp Auth) - A random string at least 32 characters long How to Fix This 1. Check your .env.server file in the root of your Wasp project. According to the environment variables documentation, you should define server environment variables there. 2. Ensure all required variables are set. For example:
DATABASE_URL=postgresql://localhost:5432/mydb
WASP_WEB_CLIENT_URL=<http://localhost:4010>
WASP_SERVER_URL=<http://localhost:3001>
JWT_SECRET=your-secret-key-at-least-32-characters-long
DATABASE_URL=postgresql://localhost:5432/mydb
WASP_WEB_CLIENT_URL=<http://localhost:4010>
WASP_SERVER_URL=<http://localhost:3001>
JWT_SECRET=your-secret-key-at-least-32-characters-long
3. If using external auth providers (Google, GitHub, etc.), make sure you've also set their required environment variables as mentioned in the deployment documentation. The knowledge sources indicate that there's an ongoing issue to improve environment variable validation and error messages, which would make it clearer which specific variable is missing in cases like yours. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Zuck, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Zuck
ZuckOP3w ago
ya i got all of those @kapa.ai
kapa.ai
kapa.ai3w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I understand you have all the standard required environment variables set. Let me help you troubleshoot further. Since the error message shows "Required" but doesn't specify which variable is missing, here are some additional things to check: Troubleshooting Steps 1. Verify the .env.server file location: According to the Discord support thread, make sure your .env.server file is in the root of your Wasp project (not in the .wasp/out directory). You can verify this by running:
ls -la .env.server

ls -la .env.server

2. Check for .env.server.example: The same Discord thread mentions copying from .env.server.example:
cp .env.server.example .env.server

cp .env.server.example .env.server

3. Verify environment variable format: Make sure your variables in .env.server follow the correct format without quotes or extra spaces:
DATABASE_URL=postgresql://localhost:5432/mydb
WASP_WEB_CLIENT_URL=<http://localhost:4010>
WASP_SERVER_URL=<http://localhost:3001>
JWT_SECRET=your-secret-key-at-least-32-characters-long

DATABASE_URL=postgresql://localhost:5432/mydb
WASP_WEB_CLIENT_URL=<http://localhost:4010>
WASP_SERVER_URL=<http://localhost:3001>
JWT_SECRET=your-secret-key-at-least-32-characters-long

4. Check for external auth variables: If you're using any external authentication methods (Google, GitHub, Discord, etc.), you need their specific environment variables as well. The knowledge sources mention variables like GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, etc. 5. Restart the development server: After making changes to .env.server, restart wasp start to pick up the new values. Could you share what environment variables you currently have set in your .env.server file (without revealing sensitive values)? This would help identify what might be missing. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Zuck, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Zuck
ZuckOP3w ago
this is the right import right? import { defineEnvValidationSchema } from 'wasp/env'; @kapa.ai
Carlos
Carlos3w ago
Yep that is correct Mmmm that's weird, it looks like we're not receiving process.env at all. You're running wasp start, right? Which wasp version are you on?
Zuck
ZuckOP3w ago
@Carlos sorry i suck at follow ups i just reset to my last commit and reimplemented and things work now
Carlos
Carlos3w ago
no problem, just happy it works now 🙂

Did you find this page helpful?