react-trello icon indicating copy to clipboard operation
react-trello copied to clipboard

[question][help] Process not defined

Open mein-beer-hu opened this issue 3 years ago • 9 comments

Describe the bug

I recently installed this library (thanks ton!). I am trying to experiment with basic example of just importing the Board and instantiating it with dummy data (from storybook).

But my app fails to run as soon as I try to use the Board component. I see following error in my console

fromRequireContextWithGlobalFallback.js:19 ReferenceError: process is not defined
    at Object../node_modules/react-trello/dist/controllers/Board.js

I am using react-functional component

Screen Shot 2021-10-12 at 11 14 00 PM

some essential packages in package.json:

...
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-trello": "^2.2.11",
    "react_ujs": "^2.6.1",
...

I am using webpacker for rails.

To Reproduce Steps to reproduce the behavior:

  1. yarn add
  2. run the local dev server
  3. app fails to load

Expected behavior App should load

Screenshots Screen Shot 2021-10-12 at 11 16 06 PM

Desktop (please complete the following information):

  • OS: Mac
  • Browser chrome
  • Version 93.0.4577.82

mein-beer-hu avatar Oct 13 '21 06:10 mein-beer-hu

Hi @mein-beer-hu, Is your app packaged with Vite? With vite I get this also, adding the following to my vite config fixes the issue for me.

export default defineConfig({
  plugins: [react()],
  define: {
    "process.env": {},
  },
});

KaiSpencer avatar Oct 14 '21 21:10 KaiSpencer

@KaiSpencer Worked for me, thanks!

christopher-caldwell avatar Nov 09 '21 21:11 christopher-caldwell

@mein-beer-hu Can you confirm this works for you also, and if so close this issue?

KaiSpencer avatar Dec 18 '21 23:12 KaiSpencer

Facing same issue with Webpack 5

karthik-hr avatar Jan 05 '22 19:01 karthik-hr

Facing same issue with Webpack 5

@karthik-hr Does this link provide a solution to your issue?

KaiSpencer avatar Jan 05 '22 19:01 KaiSpencer

@KaiSpencer The issue was with jspdf -> canvg package. process/browser causing problem. I have added following plugin for webpack and its working fine now. Thanks

new webpack.EnvironmentPlugin({ REDUX_LOGGING: false }),

karthik-hr avatar Jan 06 '22 07:01 karthik-hr

Facing same issue with Webpack 5

@karthik-hr Does this link provide a solution to your issue?

@KaiSpencer this has helped me, thanks!

hazigabriel avatar Oct 20 '22 08:10 hazigabriel

For people using esbuild, I added the following to my esbuild string (including quote marks): '--define:process.env="{}"' From here: https://github.com/evanw/esbuild/issues/12#issuecomment-587109454

WillTaylor22 avatar Dec 22 '22 14:12 WillTaylor22

I fixed this issue with the below:

new webpack.DefinePlugin({
  'process.env': {
    NODE_ENV: JSON.stringify(process.env.NODE_ENV)
  }
})

jeremylynch avatar Mar 30 '24 08:03 jeremylynch