React Native cannot find entry file in any of the roots - react-native

Description
Cloned a repo to a new computer and getting the following error:
swipes#0.0.1 start C:\a\swipes-api\mobile
node node_modules/react-native/local-cli/cli.js start
Scanning 722 folders for symlinks in C:\a\swipes-api\mobile\node_modules (30ms)
┌────────────────────────────────────────────────────────────────────────────┐
│ Running packager on port 8081. │
│ │
│ Keep this packager running while developing on any JS projects. Feel │
│ free to close this tab and run your own packager instance if you │
│ prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
C:\a\swipes-api\mobile
error: bundling: NotFoundError: Cannot find entry file index.android.js in any of the roots: ["C:\\a\\swipes-api\\mobile"]
at DependencyGraph._getAbsolutePath (C:/a/swipes-api/mobile/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:280:11)
at DependencyGraph.getDependencies (C:/a/swipes-api/mobile/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:218:26)
at Resolver.getDependencies (C:/a/swipes-api/mobile/node_modules/react-native/packager/src/Resolver/index.js:107:27)
at C:/a/swipes-api/mobile/node_modules/react-native/packager/src/Bundler/index.js:591:37
at next (native)
at step (C:\a\swipes-api\mobile\node_modules\react-native\packager\src\Bundler\index.js:12:445)
at C:\a\swipes-api\mobile\node_modules\react-native\packager\src\Bundler\index.js:12:605
at process._tickCallback (internal/process/next_tick.js:103:7)
Bundling `index.android.js` 0.0% (0/1), failed.
The path is correct where it's searching from. I've been stuck with this for the whole day now.
Is this somehow because there are double backslashes in the path to the index file?
npm start -- --reset-cache results in the same error.
Running yarn start after react-native run-android results in the same issue as well.
npm run start -- --root C:\a\swipes-api\mobile - No result.
This does not seem to be connected to the previous issue in the RN 0.45.0.
Additional Information
React Native version: 0.45.1
Platform: Android
Development Operating System: Windows
Edit:
All new projects with react-native init result in the same issue. Seems to be an issue with the config of my computer or npm, but I can't seem to track down why this happens.
Any ideas?

I have this and some like this error on windows.
Updating the npm and the node helped me on this issue.
currently i have:
C:\usr\Far>node -v && npm -v
v6.11.1
3.10.10
Many trials to run was not successful at all until I do not update. Anyway some errors like this appear time to time. Just restart. Also helpful to do before restart (but may be not need, just restart):
sh -c 'rm -rf $TMP/react*'
npm cache clean
Where $TMP is your system tmp directory, (check for existence react temp files there)
If you add or update some packages or some like that modifications concerning node_modules directory need to do also:
rm -rf node_modules && npm install

Related

React native monorepo with PNPM

My goal
I am trying to use React native monorepo with PNPM, because I need performance of pnpm.
Expected
I should be able to bundle React native app with pnpm android and start development server with pnpm start.
Actual results
I can bundle app, but I cant start metro server. I always get this error:
More info
I have node v16.14.2, react native v0.69.
I know default metro bundler doesn't support symlinks (https://github.com/pnpm/pnpm/issues/1252#issuecomment-667600769), which pnpm use, so I tried to patch metro in metro.config.js:
This works perfectly fine with pure React native repo like here e.g: https://github.com/gjhughes/react-native-pnpm-example
My project structure looks like this:
project
└───shared
└───backend
│ │ package.json
│
└───frontend
│ │ package.json
│
└───mobile-app
│ │ package.json
Here is my pnpm-workspace.yaml:
I am desperate. Is it even possible?
If you have any more questions, feel free to ask!
Use pnpm without symlinks. Create a .npmrc in the root of your monorepo with the following setting:
node-linker=hoisted
Remove node_modules and run pnpm install. Related docs: https://pnpm.io/npmrc#node-linker

The development server returned response error code: 500 URL: http://localhost:8081/index.bundle?platform=android&dev=true&minify=false

How can I solve it. Where do you think the error
The development server returned response error code: 500 URL: http://localhost:8081/index.bundle?platform=android&dev=true&minify=false
metro
/usr/local/bin/node /usr/local/lib/node_modules/react-native-cli start
(node:34741) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
┌──────────────────────────────────────────────────────────────────────────────┐
│ │
│ Running Metro Bundler on port 8081. │
│ │
│ Keep Metro running while developing on any JS projects. Feel free to │
│ close this tab and run your own Metro instance if you prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└──────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
/Users/mbp/Documents/erkan/TurRota
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `module:react-native-reanimated.Animated.log` from `src/components/Mainpage/Mapview.js`: module:react-native-reanimated.Animated.log could not be found within the project.
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules: rm -rf node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
at ModuleResolver.resolveDependency (/Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:186:15)
at ResolutionRequest.resolveDependency (/Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (/Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
at Object.resolve (/Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/lib/transformHelpers.js:267:42)
at /Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/DeltaBundler/traverseDependencies.js:426:31
at Array.map (<anonymous>)
at resolveDependencies (/Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/DeltaBundler/traverseDependencies.js:423:18)
at /Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/mbp/Documents/erkan/TurRota/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
BUNDLE [android, dev] ./index.js ▓▓▓▓▓▓░░░░░░░░░░ 41.6% (620/1016), failed.
::ffff:127.0.0.1 - - [13/Jan/2021:09:43:18 +0000] "GET /index.bundle?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"
In my case This is a bug on version 0.56. so, suggest you to downgrade from 0.56 to version 0.55 just run this command
npm install react-native#0.55.4 --save

getting error "error: unknown option `--nonPersistent" when using expo publish

I have build an app using expo init and it is working perfectly fine with "expo start". But when I wanted to publish it using "expo publish", i get the error.
(base) hemant#hemant-hp:~/Desktop/Chatter-Native$ expo publish
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ │
│ There is a new version of expo-cli available (3.11.2). │
│ You are currently using expo-cli 3.2.3 │
│ Install expo-cli globally using the package manager of your choice; for example: `npm install -g expo-cli` to get the latest version │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Unable to find an existing Expo CLI instance for this directory, starting a new one...
error: unknown option `--nonPersistent'
Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
(base) hemant#hemant-hp:~/Desktop/Chatter-Native$
maybe it's because you are using a old version of expo-cli, upgrade your expo-cli and try again. you can get a more detailed log of your error runing $export EXPO_DEBUG=true and runing again expo publish

Need help understanding hashes in `npm audit` output

in my npm audit output I saw the following entry with a hash:
├───────────────┼─────────────────────────────────────────┤
│ Path │ 050fb87979f5c6895917ef26a696d57ebf3cf1… │
│ │ > mocha > growl │
├───────────────┼─────────────────────────────────────────┤
May I know what the hash stands for and where can I find the dependency tree node it represents? I searched online and searched through my package-lock.json file but couldn't find it.
Thanks!
Somehow I was able to figure it out not long after posting it, by using npm ls growl. It shows that the hash represents an internal package. (The confusing part is that some internal packages were displayed by package name in npm audit output while some were displayed as hashes. | Update: it turns out that we are importing some package by their git commit directly, in those case those dependencies are displayed as hashes.)
I just ran into the same issue. The issue is to obscure the package name for security reasons. After looking into the npm docs this has been resolved in Version 7. I just ran npm audit using npm 7+ and it has pointed to the exact packages that are the culprit with no hash.

Share node_modules installation between sub-projects, while maintaining separate package.json files

I have the following folder structure:
project
├───components
│ ├───component-one
│ │ package.json
│ │
│ └───component-two
│ │ package.json
│ │
│ └───node_modules
├───node_modules
└───package.json
Project root project folder contains package.json and is intended to have various infrastructural modules installed (Gulp, for example, as the build is centralized).
Each component under components folder is eventually, after build and whatnot, is deployed somewhere to be consumed by an application - using the usual npm install from folder or tarball. For that reason, each component must maintain its own dependencies in its own package.json.
Going the trivial route, installing node_modules into each of the component folders would lead to a crazy amount of duplication, as there may be 100s of components, each installing mostly the same dependencies.
Ideally I would like to:
run, for example, npm install -D <module> in component-one folder
have package.json in that folder updated with the <module>
have <module> installed in the project folder
This can be achieved, to some extent, running (on Windows, in this case) mklink /D node_modules ..\..\node_modules from component-one to create a symlink.
However, symlinks are fragile and finicky, so I'd like to avoid that solution.
Is there an npm solution, via npm link or something that I am missing?