1

I'm not using create-react-app

I tried putting this at the top of my React component's tsx file:

require('dotenv/config');
const slackUrl = process.env.JOIN_URL;

And I get: Error: Can't resolve 'fs' in 'node_modules/dotenv/lib' at webpackMissingModule

I've installed dotenv via package.json, so not sure what else I need to resolve this.

I'm running the site locally with webpack.

This also did not work, same error:

// eslint-disable-next-line @typescript-eslint/no-var-requires
require('dotenv').config();

console.log(`process.env.JOIN_URL: ${process.env.JOIN_URL}`);
const slackUrl = process.env.JOIN_URL;

I also put this in my package.json, but didn't make any difference:

"browser": {
  "fs": false
},
PositiveGuy
  • 17,621
  • 26
  • 79
  • 138

0 Answers0