Unable to resolve module 'fs' from 'node_modules/react-native-dotenv/index.js'
See original GitHub issueI just found the new update of this package. And wanted to update it in order to keep my project up to date.
But when I try to execute it I got this error.

I’m on Expo SDK V37
Package.json
"@react-native-community/masked-view": "0.1.6",
"@react-navigation/bottom-tabs": "^5.5.2",
"@react-navigation/native": "^5.5.1",
"@react-navigation/stack": "^5.5.1",
"expo": "^37.0.3",
"expo-constants": "~9.0.0",
"expo-facebook": "~8.1.0",
"expo-google-app-auth": "^8.1.0",
"expo-image-picker": "~8.1.0",
"expo-secure-store": "~8.1.0",
"firebase": "7.9.0",
"native-base": "2.13.8",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-dotenv": "^2.2.0",
"react-native-elements": "^1.2.7",
"react-native-gesture-handler": "~1.6.1",
"react-native-image-viewing": "^0.2.0",
"react-native-modal": "^11.5.6",
"react-native-reanimated": "~1.7.0",
"react-native-render-html": "^4.2.0",
"react-native-responsive-fontsize": "^0.4.2",
"react-native-safe-area-context": "0.7.3",
"react-native-screens": "~2.2.0",
"react-native-svg": "11.0.1",
"react-native-swiper": "^1.6.0",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.12.3",
"react-native-webview": "8.1.1",
"styled-components": "^4.4.1"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^24.0.25",
"@types/react": "^16.9.23",
"@types/react-native": "^0.61.17",
"@types/react-test-renderer": "^16.9.2",
"@types/styled-components": "^4.4.2",
"babel-plugin-module-resolver": "^4.0.0",
"babel-preset-expo": "^8.1.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-react-16-adapter-setup": "^0.1.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-react-native-wcandillon": "^2.6.0",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-plugin-import": "^2.18.2",
"jest": "^25.1.0",
"jest-environment-enzyme": "^7.1.2",
"jest-enzyme": "^7.1.2",
"jest-expo": "^37.0.0",
"jest-mock-extended": "^1.0.8",
"ts-mockito": "^2.5.0",
"typescript": "^3.8.3"
},
.babelrc
"presets": [
"module:metro-react-native-babel-preset",
"babel-preset-expo"
],
"plugins": [
[
"module:react-native-dotenv", {
"moduleName": "@env",
"path": ".env",
"blacklist": null,
"whitelist": null,
"safe": false,
"allowUndefined": false
}
],
Issue Analytics
- State:
- Created 3 years ago
- Reactions:22
- Comments:9 (2 by maintainers)
Top Results From Across the Web
React Native: Unable to resolve module fs - Stack Overflow
I ended up using 'rn-nodeify' to include fs into React Native. You can use most of the node core modules this method. Install...
Read more >Module not found | Can't resolve 'fs' in Next js application
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >module not found can't resolve 'fs' react - You.com
The fs and net modules are not browser-compatible code. They depend on APIs which are provided by Node.js and which are not provided...
Read more >react-native-fs - npm
Native filesystem access for react-native. Latest version: 2.20.0, last published: 8 months ago. Start using react-native-fs in your project ...
Read more >Failed to resolve module specifier 'fs' ? help : r/node - Reddit
js extension which I fixed, then came the last one where Chrome is saying it can't resolve the path to the node module...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can you verify that you replaced all ‘react-native-dotenv’ imports with the ‘@env’ import?
That should do the trick! (‘fs’ is not available on react-native, however this code is really needed at build time only)
@twom Worked for me 😄
Example:
import { API_HOST } from '@env'