W
Wasp-lang5mo ago
mgp25

Can't find variable: process

I am lately getting ReferenceError: Can't find variable: process which is caused by /server/config.ts and points to:
all: {
env,
isDevelopment: env === 'development',
port: parseInt(process.env.PORT) || 3001,
databaseUrl: process.env.DATABASE_URL,
allowedCORSOrigins: [],
auth: {
jwtSecret: undefined
}
},
all: {
env,
isDevelopment: env === 'development',
port: parseInt(process.env.PORT) || 3001,
databaseUrl: process.env.DATABASE_URL,
allowedCORSOrigins: [],
auth: {
jwtSecret: undefined
}
},
As far as I know, this should be only run in the server and not the client and therefore causing the error. I have not changed anything within the Wasp Project. No matter what I do, once I run wasp start the project only shows a blank page with that error in the web console. Any idea what could happen? OS: MacOS Node version: 18.20.3 Wasp version: 0.13.2
1 Reply
kapa.ai
kapa.ai5mo ago
Hi @mgp25. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This error typically occurs when server-side code is being executed in the client context, which should not happen. The process variable is not defined in the browser, hence the error. Here are a few things you can check: 1. Ensure that you are not importing anything from wasp/server/* on the client side. This could cause server-side code to be executed in the client context. 2. Check if you have any TODOs in your code related to the recent migration. This could potentially be causing the issue. 3. If you are using @wasp/shared, try changing it to a relative import. For example, change
import {
//...
} from '@wasp/shared/constants';
import {
//...
} from '@wasp/shared/constants';
to
import {
//...
} from '../../shared/constants';
import {
//...
} from '../../shared/constants';
4. Ensure that your .env.server file is in the correct place. It should be inside the app folder. 5. Try adding PORT=3001 to your .env.server file. If that fixes it, then somehow your app is picking up that you're not in the development environment. If none of the above solutions work, it would be helpful if you could provide more information or a reproducible example. This could be a specific part of your app or more error logs around the issue. Sources: - Discord support thread: Error building after migrating Wasp to 0.12 (https://discord.com/channels/686873244791210014/1212533517360177253) - Github Issue (open): Implement good support for environment variables (https://github.com/wasp-lang/wasp/issues/175) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mgp25, 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?
Want results from more Discord servers?
Add your server