diff --git a/CHANGELOG.md b/CHANGELOG.md index 89208a99..925d2fc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. See [standa ## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.1.0...master) +## [16.1.3](https://github.com/motdotla/dotenv/compare/v16.1.2...v16.1.3) (2023-05-31) + +### Removed + +- Removed `browser` key in package.json. These were set to false incorrectly as of 16.1. Instead, if using dotenv on the front-end make sure to include polyfills for `path`, `os`, `fs`, and `crypto`. [Browserify](https://browserify.org/) provides these. + ## [16.1.2](https://github.com/motdotla/dotenv/compare/v16.1.1...v16.1.2) (2023-05-31) ### Changed diff --git a/README.md b/README.md index 3348581c..0c89d20f 100644 --- a/README.md +++ b/README.md @@ -525,6 +525,20 @@ There are two alternatives to this approach: 1. Preload dotenv: `node --require dotenv/config index.js` (_Note: you do not need to `import` dotenv with this approach_) 2. Create a separate file that will execute `config` first as outlined in [this comment on #133](https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822) +### Why am I getting the error `Module not found: Error: Can't resolve 'crypto|fs|os|path'`? + +You are using dotenv on the front-end. Webpack < 5 used to include polyfills for core Node.js modules like `crypto`, `fs`, `os`, and `path`. So today, you need to install and configure a polyfill for it. + +```bash +npm install crypto-browserify +``` + +And then configure it in your webpack config. + +```json +resolve.fallback: { "crypto": require.resolve("crypto-browserify") } +``` + ### What about variable expansion? Try [dotenv-expand](https://github.com/motdotla/dotenv-expand)