i’m getting this error below trying to use both dotenv and config. I’ve got a Typescript React App, just installed and need to use environment variables.
I don’t have webpack installed as a dependency as i’m using react-scripts (not an expert on either of them, just want to clarify).
I tried doing what it said about including a polyfill, I even tried using dotenv-webpack
. None of this works and it only led to further issues.
Is there anything I can do to solve this?
When I create a webpack config file, should it automatically work when I use react-scripts? I tried using webpack to run it as well but the webapp doesn’t work.
Node Version: 20.11.0
Webpack Version: 5.93.0
React Version: 18.3.1
ERROR in ./node_modules/config/lib/config.js 10:13-28
Module not found: Error: Can't resolve 'path' in '/Users/x/Documents/x/Programming/x/node_modules/config/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
ERROR in ./node_modules/config/lib/config.js 11:19-32
Module not found: Error: Can't resolve 'fs' in '/Users/x/Documents/x Programming/x/node_modules/config/lib'