Next.js Discord

Discord Forum

Environment variable in packages folder

Unanswered
Jindo posted this in #help-forum
Open in Discord
JindoOP
Can you place .env in the packages folder?

I have this project structure below:

- apps - project1 - project2 - packages - shared - ui - components - utils - layouts - index.ts - package.json



Is it possible to place the .env file in the packages > shared > ui folder since I have a reusable function that I'll place in the utils that I can reuse in multiple projects in the apps folder.

7 Replies

@!=tgt it has to be in the root directory
JindoOP
It actually works when on the
apps > project1.

but on packages > shared > ui,
it works but there is an error like process undefined.
you can try to symlink it
@!=tgt Yeah it has to be in the root
JindoOP
I already symlink it.
It works on the apps > project1
and it also works on the packages > shared > ui, but it has an error.