Attempted to access server-side environment variable 'NODE_ENV' on the client Error
Hi, i am trying to call a trpc user mutation that will update the user settings ( name, email and avatar), whenever i call the mutation it returns the error on the title, i don't know why, if i use an alternative method ( via nextjs request ) , it works perfectly. Here's my code:
10 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
that didnt worked
the same error happens when i try to run a normal query
getting user count for example
i followed this, and it's exactly how i did it https://www.nexxel.dev/blog/ct3a-guestbook
Shoubhit Dash
Build a Full Stack App with create-t3-app
Let's build a guestbook with all parts of the T3 stack - Next.js, tRPC, Prisma, Tailwind CSS and Next Auth
but mine doesnt work...
After tracing the "error" with chatgpt help, this what he responded to me after a long conversation:
The error message says that there is an attempt to access the server-side environment variable NODE_ENV on the client, and this is not allowed.
The error trace shows that the error occurred in the loggerLink module of the @trpc/client library, which is part of a larger stack of modules that involve the @trpc and @tanstack/query-core libraries.
It seems like there is a misconfiguration or a misusage of these libraries, which is leading to the attempt to access the NODE_ENV environment variable on the client. One possible cause is that the code is running in a client-side context where this variable is not available, but it is being used as if it were.
To diagnose the issue further, it may be necessary to look at the code that is using these libraries and see if there are any places where the NODE_ENV variable is being used. It may also be helpful to check the documentation and the issue tracker of these libraries to see if there are any known issues or similar cases.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
@Diogovski have you resolved this issue bro ?
If i remember correctly, deleting all trpc files and create them again solved it
because i keep having this issue even tho i haven't even touched the env.mjs
@Diogovski when you mean i can just remove all and copy paste it back