process.env is empty
I am using env vars
I created
//.env.development
PLASMO_PUBLIC_WEB_SITE_URL=VALUE
I can use this value in package.json but can't load anything in code. It's empty

38 Replies
It used to work but now it's not.
I run with regular pnpm dev
I tried on 0.82.1
0.82.6
0.83.0
if you do
console.log(process.env.PLASMO_PUBLIC_WEB_SITE_URL)
, does it work?
the process.env object is partial populated but it's just for dev server polyfill
The env itself will be statically replaced in the final bundle
thx for reply
interesting thing that it works in my manifest
exact the same env var

@belarusrulez has reached level 2. GG!
I can see changes if I change PLASMO_PUBLIC_WEB_SITE_URL in .env.development and readd extension
so It's definetelly works in package.json

I checked on few versions
even 0.67
Older version has to work tho :d..
Where's this file located btw?
How is it being imported? Only files that were statically analyzed and compiled by plasmo woud get the env injected
Can you try replicating the issue in https://github.com/PlasmoHQ/examples/tree/main/with-env
GitHub
examples/with-env at main · PlasmoHQ/examples
🔰 Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - PlasmoHQ/examples
Funny thing it was working few weeks back
I had few env vars that were filling up and working ok
By the look of it, it looks like an
index.js
- is it imported into background.ts
?
hmm...Ill try to revert my code for few weeks
try doing
--verbose
and look at the first few lines of log, see if it recognize your env
It could also be that
one of the env was malformed
which botched the rest of the env file
if you isolate just 1 string env, does it work?yea it sees .env.development
I trieed all aproaches
.env
.env.local
.env.bla-bla and pass via terminal param
Ill try to revert and see what's going on
yeah this sounds rather bizzare
strange it works in package.json
esp if it worked before and suddenly not work now :d...
did you change your src location by any chance?
can it be some new package overrides it?
I don't think so - process.env will be statically parsed and replaced by the static value at compile time
unless your new package has some weird side effect at the compilation level (i.e, it hooked into the parcel build process somehow which are sharded into 4 child workers), I don't think it can overwrite the process.env :d
I started to use sst
sst
?SST
SST
Build modern full-stack serverless applications on AWS with Next.js, SvelteKit, Remix, Astro, Solid, and more.
it's in pnpm root workspace
Ill try to revert and let you know
it's so wierd lol
does sst mangle the build somehow?
is the build process being run in some cloud env?
afaik plasmo should be able to coexist with sst - they are separate build tools
Also this code is pointing to the source file via sourcemap right? It's not compiled.
have no idea but think so because they inject env vars
all screenshots from my laptop
the think is I removed package that had sst in deps and still have the same problem 😄 trying to revert/or delete some code

@belarusrulez has reached level 3. GG!
I removed all files except background/index.ts
and as you can see all packages not in node_modules as well



I tried https://github.com/PlasmoHQ/examples/tree/main/with-env after I renamed env file to .env.development all works as expected
GitHub
examples/with-env at main · PlasmoHQ/examples
🔰 Example projects that demonstrate how to use the Plasmo Framework and integrate with popular tools - PlasmoHQ/examples

and manifest in .plasmo is correct
with inserted env var
figured it out.

it was importing
that is not needed.