question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

process not defined

See original GitHub issue

What version of Remix are you using?

1.3.5

Steps to Reproduce

use process inside a component like below:

function Component() {
    return (
        <div>
            {process.env.DOMAIN === "example.com" ? "Is main domain" : "Not main domain"}
        </div>
    )
}

Expected Behavior

Should be work as it work before

Actual Behavior

Somehow it start throwing process is not defined

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chang-ryancommented, Dec 10, 2022

i get this problem when trying to import another package.

for example

import { PaperSDKProvider, LoginWithPaper } from "@paperxyz/react-client-sdk";

this is a package that uses process in its code. and it’s breaking when using npm run dev with remix

any ideas on how to workaround this? can we put a process into global vars for the client side? is there any way in remix to inject a process.env var globally into client side just to fake it.

i assume any other client sided packages/dependencies that have process.env references in its source will break as well in remix then

1reaction
sergiodxacommented, May 5, 2022

@brightpixels process.env only works server-side (it’s a Node thing) with the exception of process.env.NODE_ENV which is hardcoded on build, for any other env variable use the loader to read the value and return it.

This is documented here https://remix.run/docs/en/v1/guides/envvars

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: “process is not defined” - GIMTEC
In this case, process is not defined in the browser environment, hence the error. The solution is to remove the reference to process...
Read more >
javascript - Uncaught ReferenceError: process is not defined
I am using the command "npm start" which refers to the "start" script inside package.json that is set to "start": "http-server -a localhost...
Read more >
"Uncaught ReferenceError: process is not defined" and the ...
The Uncaught ReferenceError: process is not defined happens when when a non-existent (here: process) variable is referenced .
Read more >
process is not defined (NOT react-error-overlay ... - GitHub
Using the optional chaining operator with process ( process?.env ) throws a ReferenceError stating that process is not defined.
Read more >
Uncaught ReferenceError: process is not defined
The error Uncaught ReferenceError: process is not defined may happen when the code tries to get access to the process object that provides ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found