Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package initalization Error #512

Open
RameshTigeen opened this issue Jan 8, 2025 · 3 comments
Open

Package initalization Error #512

RameshTigeen opened this issue Jan 8, 2025 · 3 comments
Assignees

Comments

@RameshTigeen
Copy link

Description
When running the React Native project, an error occurs related to the path module in react-native-dotenv. The error message states that the path module could not be found within the project or in the directories like node_modules. This results in the build process failing with a module resolution error.

Steps to Reproduce
Create a new React Native project or use an existing one.
Install and configure react-native-dotenv to load environment variables.
Attempt to run the app with the command npm run android (or npx react-native run-android).
The error message is thrown, and the build process fails.
Expected Behavior
The project should build successfully, and the environment variables should be loaded properly using react-native-dotenv.

Actual Behavior
The build fails with the following error message:

 Error: Unable to resolve module path from D:\React Native\devutilsapp\node_modules\react-native-dotenv\index.js: path could not be found within the project or in these directories:
  node_modules
  1 | const fs = require('fs')
> 2 | const path = require('path')
    |                       ^
  3 | const dotenv = require('dotenv')
  4 |
  5 | function parseDotenvFile(path, verbose = false) {
    at ModuleResolver.resolveDependency (D:\React Native\devutilsapp\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:148:15)
    at DependencyGraph.resolveDependency (D:\React Native\devutilsapp\node_modules\metro\src\node-haste\DependencyGraph.js:235:43)
    at D:\React Native\devutilsapp\node_modules\metro\src\lib\transformHelpers.js:160:21
    at resolveDependencies (D:\React Native\devutilsapp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:42:25)
    at visit (D:\React Native\devutilsapp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:83:30)
    at async Promise.all (index 2)
    at async visit (D:\React Native\devutilsapp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:92:5)
    at async Promise.all (index 2)
    at async visit (D:\React Native\devutilsapp\node_modules\metro\src\DeltaBundler\buildSubgraph.js:92:5)
    at async Promise.all (index 0)

Environment
OS: Windows 10
React Native Version: 0.75.1
Node Version: v21.7.3
Package Manager: npm
react-native-dotenv Version: Latest

Additional Information
The error might be related to the use of core Node.js modules (like path) in React Native, which doesn't natively support some of these modules.
Possible solution could involve checking for a compatibility issue between react-native-dotenv and the current React Native version, or ensuring the appropriate polyfills are used for Node.js core modules.

Copy link

github-actions bot commented Jan 8, 2025

Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/512

@RameshTigeen RameshTigeen changed the title Error: While Import the Dotenv Package initalization Error Jan 8, 2025
@raduiamandi-pilot
Copy link

I think it happens with 'os' package too.

@RameshTigeen
Copy link
Author

did anyone have same issues like me i am holding this issues for almost two week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants