New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.env files are ignored in monorepo subpackages #4110
Comments
i used to config my env configure in npm hooks like: // package.json
{
...
"scripts": {
"start": "APP_ENV=local parcel serve",
"build:dev": "APP_ENV=develop parcel build",
"build:prod": "APP_ENV=production parcel build"
},
...
} wish some helps for u~ |
@cdll I have several more env vars so that would be very annoying to do. |
The problem is parcel reads the env vars from the root of the package and not the packages inside this monorepo. I'll try to make a PR and fix this. |
Related: #3942 (comment), #3942 (comment) |
Yeah that's probably the same issue to those comments. It would be good for parcel to read all env files from the monorepo root down to the package dir, updating values as it travels down. Or should the root .env.local be more important than the package .env.local? |
I'd say no. |
Hi! I'm trying to deploy a project bundled with Parcel using Netlify. I am following Robert Cooper's instructions:
And:
I am currently not commiting the |
what's the current status of this issue? Seems very important to still open. |
Same here. In my case I'm trying to use async function renderApp() {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
await import('stuff');
}
render(<App />, document.getElementById('root'));
} I'm using Using latest version (2.0.0-beta1). |
@alessandrojcm You don't need to specify NODE_ENV explicitly in your case. |
Stumbled upon the same problem today. Would be good to provide some options to overwrite |
In my case, i solved it by adding the entrie file path in package.json. "scripts": {
"start": "parcel",
"build": "parcel build src/index.html"
} |
Hey, is this still going to happen? Just came across this issue last night and I was really scratching my head figuring this out. |
I tried this, but it didn't work in my case. |
This works for me too thanks!!! |
I just ran into this problem as well. I will have to completely stop using parcel for any projects if this isn't updated. |
This should be fixed now in the latest nightly version by #7537 Try using |
@mischnic, @devongovett can you confirm that
is fixed? It still does not work for me, testing with build ^2.0.0-nightly.1071 |
I'm also still having trouble loading I'm using the latest 2.6.0 |
I am using |
Yes, currently it only searches for dotfiles in the project (=monorepo) root parcel/packages/core/core/src/loadDotEnv.js Lines 18 to 35 in 3b3b135
|
Spent a couple days trying to solve this for myself. I tried using The only feasible "workaround" I stumbled upon was the one mentioned in here #4264, which is to use |
A pretty easy way to use the
|
Are they planning to fix this bug? |
I just want to point out that the root cause of this issue is being discussed here: #7579 and that this workaround while imperfect is doing the job (mostly). |
🐛 bug report
I'm trying to provide environment variables to select a couple of values on build time, however the env files (as described here) are being ignored.
🎛 Configuration (.babelrc, package.json, cli command)
.env
.env.development
config.ts
🤔 Expected Behavior
config.ts
should export😯 Current Behavior
config.ts
exportsUpon further inspection (inserted
debugger
inside config.ts) I see thatprocess.env.NODE_ENV
is set todevelopment
(as expected), butprocess.env.API_ENDPOINT
andprocess.env.PROJECT_PACKAGE
are bothundefined
.💻 Code Sample
See above
🌍 Your Environment
The text was updated successfully, but these errors were encountered: