React Native Navigator - javascript

I created a basic react native app just to practice.
As a first step, I followed the docs below to create a navigation from one page to another:
https://reactnative.dev/docs/navigation
I'm using React Native CLI, and installed:
npm install #react-navigation/native #react-navigation/native-stack
npm install react-native-screens react-native-safe-area-context
and I copied the code from the docs to my App.js file. When I'm hitting npx react-native run-android, I'm getting the following error:
error: Error: Unable to resolve module react-navigation from C:\Users\sh\NewProject\App.js: react-navigation could not be found within the project or in these directories:
node_modules
I tried to delete node_modules and did npm install - didn't help.
Any idea how to resolve this? thanks

This error comes when library is not linked up or properly not imported. Please uninstall and try to install it again step by step.

Related

create-react-app not working ?? Any Help is Appreciated

just tried creating my first react app but surely react is not in a mood to welcome me.
Just after installing everything node and create-react-app even checking their versions to make sure they are installed.I moved on to creating the react app using npm create-react-app my-app command but it has given me this error and i am not able to resolve.
Any HELP will be appreciated.
I even tried updating the config file but Showed these errors as well.
As specified in the create-react-app github repository wiki. Please go through the detailed step by step instructions.
npx
npx create-react-app my-app
(npx is a package runner tool that comes with npm 5.2+ and higher)
npm
npm init react-app my-app
npm init is available in npm 6+
Yarn
yarn create react-app my-app
Reference Link: https://github.com/facebook/create-react-app#creating-an-app

Cannot install react native dependencies using expo-cli

I have a new React-Native project up and running using expo. I am trying to install the react navigation dependencies. I followed the instructions in the docs, I downloaded "#react-navigation/native": "^5.7.1", and "#react-navigation/stack": "^5.7.1" using NPM. Then when I run expo install react-native-reanimated, it throws the error Unexpected end of JSON input. I am using node version 14.6.0 and I have installed the expo-cli globally.
You need to clean your npm cache...
In your command line run npm clean cache
Try to do what I said above... It should work...

Module not found: Can't resolve '#material-ui/core/Container'

In the browser, I get the error
Failed to compile Module not found: Can't resolve
'#material-ui/core/Container'
It's looking for the component inside of my components directory instead of node_modules. I can't change directories into node_modules ../../ because node_modules is outside of src directory and Create React App won't let me.
I've use yarn to remove and $ yarn add #material-ui/core. I've tried yarn run build which gives me the error
Cannot find module: '#material-ui/core/Container'. Make sure this
package is installed. You can install this package by running: yarn
add #material-ui/core/Container.
When I try to add it, I get the error
error Couldn't find package "#material-ui/core/Container" on the "npm"
registry.
Here's the dependencies I have that are related:
"#material-ui/core": "^3.9.3",
"#material-ui/icons": "^3.0.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
I expect to see the contents of the page not take up the full width of the screen, but instead, I receive a fail to compile error.
Container is not part of the material-ui version specified in your package.json.
To upgrade, run the following:
$ yarn add #material-ui/core#next
You might have to remove the old stable version (if that's even an option for you).
React and react-dom >= 16.8.0 are all that are needed as peer dependencies, so the experimental upgrade of material-ui should be all you need to use Container.
I had a similar issue and I resolved it by calling:
for npm:
npm install #material-ui/core
for yarn:
$ yarn add #material-ui/core#next
If you follow a npx create-react-app new-app with cd new-app and yarn add #material-ui/core it wile compile with yarn start. You might try just starting over.
However, to help your troubleshooting, this error typically happens when you try to use a Material-UI component and forget to import it. Have you tried commenting out all the code and seeing if it compiles?
This error might also indicate that there are no node_modules for what is being imported. So, npm install might solve the problem.
Just install these below packages
#emotion/react
#emotion/styled
#material-ui/core
#material-ui/icons
Just Install: npm install #material-ui/core
This problem is caused by the same material UI package you have installed, latest MUI package is written as #mui/package-name and I installed material-ui-dropzone package and this package does not adapt to new material UI name conversion means it uses the old naming conversion of MUI, for example, #material-ui/package-name
The solution for this problem will be to install core material UI and other MUI packages using the old naming conversion for example #material-ui/core or #material-ui/icons instead of #mui/core or #mui/icons
For those trying to upgrade to Material Ui v5 (MUI v5)
See this section of the migration doc to v5.
Some imports have changed name (not just the prefix)
#material-ui/core -> #mui/material
#material-ui/unstyled -> #mui/base
#material-ui/icons -> #mui/icons-material
[...]
you haven't installed Material-UI for the correct path.
step 1:
If windows-PC selects the correct path using terminal -> cd .\foldername
step2:
install Material-UI
// with npm
npm install #material-ui/core
// with yarn
yarn add #material-ui/core

Metro Bundler error in installing own npm package

I have created this npm package. After installing it in another app and running it, I get the error:
Metro Bundler has encountered an internal error
This happens even if the project is a newly initialised one. What is wrong in my npm package?
Probably because in your index.js file you have
import App from "./src/App";
but there is no such file in your repo.

Error after installing react-native-elements package

I installed react-native-elements through npm a while ago. This morning, I was trying to create an Overlay component from the package, but for some reason I kept getting an error that no such component existed. So, foolishly, I ran npm install react-native-elements again, and now every time I try to build I get the following error:
Unable to resolve ./social/SocialIcon" from "./C:\\Users\\L\\IdeaProjects\\FinalProject\\node_modules\\react-native-elements\\src\\index.js: The module ./social/SocialIcon could not be found"`.
I have react-native-vector-icons installed. I have no idea why this is happening.
Try install #expo/vector-icons
npm install #expo/vector-icons --save
https://github.com/react-native-training/react-native-elements/issues/620

Categories