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.

ReferenceError: process is not defined

See original GitHub issue

image

I didn’t find process was used in webpack config file, so what might cause this kind of error

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
timurcataklicommented, Sep 22, 2021

I fixed this issue by adding below to webpack v5

      new webpack.DefinePlugin({
        process: { env: {} },
      }),
2reactions
flunderperocommented, May 18, 2021

Here it is (with all the unrelated stuff 😃 ):

const path = require("path")
const webpack = require("webpack")

module.exports = {
    assetsDir: "tests/__assets__",
    title: "Last React Material",
    components: "components/*.tsx",
    defaultExample: true,
    require: [path.join(__dirname, "./components/mdc_all.scss")],
    styleguideDir: path.join(__dirname, "dist", "docs"),
    showSidebar: true,
    pagePerSection: true,
    template: {
        head: {
            links: [
                {
                    rel: "preconnect",
                    href: "https://fonts.gstatic.com",
                },
                {
                    href:
                        "https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined",
                    rel: "stylesheet",
                },
                {
                    href: "https://fonts.googleapis.com/css2?family=Roboto:wght@300;400",
                    rel: "stylesheet",
                },
            ],
        },
    },
    theme: {
        fontFamily: {
            base: '"Roboto", sans-serif',
        },
        fontSize: {
            text: 15,
            h1: 36,
            h2: 24,
            h3: 18,
            h4: 16,
            h5: 15,
            h6: 15,
        },
        baseBackground: "#fdfdfc",
        border: "#e0d2de",
    },
    sections: [
        {
            name: "Introduction",
            content: "README.md",
        },
        {
            name: "Components",
            components: "components/*.tsx",
            exampleMode: "collapse",
            usageMode: "expand",
            sectionDepth: 1,
        },
    ],
    webpackConfig: {
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    loader: "ts-loader",
                    exclude: /node_modules/,
                    options: {
                        transpileOnly: true,
                    },
                },
                {
                    test: /\.scss$/,
                    use: ["style-loader", "css-loader", "sass-loader"],
                },
            ],
        },
        resolve: {
            extensions: [".tsx", ".ts", ".js", ".jsx", ".scss"],
        },
        plugins: [
            new webpack.DefinePlugin({
                process: {env: {}},
            }),
        ],
    },
}
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 >
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" and the ...
The Uncaught ReferenceError: process is not defined happens when when a non-existent (here: process) variable is referenced .
Read more >
React ReferenceError: process is not defined | bobbyhadz
To solve the "Uncaught ReferenceError: process is not defined" in React, open your terminal in your project's root directory and update the version...
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