Cannot resolve 'react-native' - reactjs

I am trying to import react-native module into my react app. When I start my app server using 'npm start', I get the following error :
Module not found: Can't resolve 'react-native'
I have done following steps:
cleaned npm cache using 'npm cache verify'
deleted node_modules
rerun the command 'npm install'
checked package.json file if it has react-native dependency listed
Nothing worked for me. Please help!!

Try to recreate your app using the react native CLI. Use the command npm install -g react-native-cli, then use react-native init ProjectName and after that try to run the project.
If you cannot create a new app for any reason, try to install the react-native-cli anyway and try to run react-native run-android or react-native run-ios (depending on the plataform you want to use as a tester_ instead of npm start.

Related

npx create-react-app has suddenly stopped working

I've been running 'npx create-react-app' for my projects for the last few months however today when I tried to run the command to create a new project I got this error:
Error Message
I've tried clearing my cache, running 'npx create-react-app#latest' with no luck so far.
Try clearing legacy-peer-deps
npx create-react-app myapp --legacy-peer-deps
I recently tried creating a new React project on React 18 with create-react-app and ran into this.
The following worked for me:
Open the project via vs code (or any other terminal) and run the npm install command again to install the dependencies:
npm install
If after running the above command, the same error still persists, try:
npm install --legacy-peer-deps
It's a bug, we have to wait until the next update but you can try to install it and remove the node_module and after change the react-dom and react to a lower version like 17.0.2

Why can't I start a React project with npx?

I'm going in circles with npx trying to start a new project. Here's what I get:
"PS C:\Users\John\Documents\WebSites\react_projects> npx create-react-app material-ui
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
"You are running create-react-app 4.0.3, which is behind the latest release (5.0.0).
"We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
npm uninstall -g create-react-app
yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/"
When I type npm uninstall -g create-react-app, I get "up to date, audited 1 package in 495ms. found 0 vulnerabilities."
So I try to create the app again with npx, and I get this:
"Need to install the following packages:
create-react-app
Ok to proceed? (y)"
So I press y, and I get the first error message again. I just go in circles. How can I fix this?
Refer to official reactjs website you need to have ""Node >= 14.0.0 and npm >= 5.6"" on your machine. https://reactjs.org/docs/create-a-new-react-app.html .
Also yarn create is available in Yarn 0.25+
so you might want to check these versions
npm
stands for node package manager. It helps to install, migrate apps by adding dependencies in package.json file. You only need to run npm i. For example in react API call npm i axios you should run and import in file in order to use axios features. Also all you need to have is package.json following dependencies and packages will be added(except node_modules folder as it comes with packages and more in size).
You can use npm to start, build, eject, watch and test.
npx is a CLI tool which provide way to install and manage dependencies hosted in npm registry. It is bundled with npm since 5.2.0v. It is helpful in installing and getting started with frontend JS libraries like reactjs, angularjs, vuejs, Sveltejs or boilerplate apps.

Unable to create new react app with npx create-react-app

I am trying to create new react app with npx create-react-app [name] command. But I get following error:
error Couldn't find package "#babel/plugin-transform-flow-strip-types#7.9.0" required by "babel-preset-react-app#^9.1.2" on the "npm" registry.
Each time it is saying some package could not be found on npm registry (not only #babel/plugin-transform-flow-strip-types#7.9.0 this package).
I have also updated my npm and npx, but no success.
You can try deleting the .npmrc file located in Users/you/.npmrc and run the command again, seems there is a bug with npm and this is a workaround

Trying to build a create-react-app project with expo, throws error about react-native

I've created my react app using create-react-app, and was trying to use expo, but its throwing errors when I try and build it using expo build:android:
Error: Can't find react-native in package.json dependencies
Error: React Native is not installed. Please run `npm install` in your project directory.
Do I need to start over with a react-native project, or is there a way to continue on and get this project published?
I suggest you create your project using the expo docs :
npm install expo-cli --global
expo init my-new-project
cd my-new-project
expo start
Try this:
Remove node_modules folder.
run "yarn install".
run "expo start".
This looks like a similar issue on this github error
https://github.com/expo/expo-cli/issues/248

Unable to add angular component inside nodeJS express project

I am new to node with angular.
I created a new express project, and then added a new folder called assets.
I ran the following commands:
npm uninstall -g #angular/cli
npm cache clean
npm install --save-dev #angular/cli#latest
Then I went to assets folder and tried to create an angular component:
ng generate component app
And i've got the following error:
Unable to find "#angular/cli" in devDependencies.
Please take the following steps to avoid issues: "npm install --save-dev #angular/cli#latest"
Unable to find any apps in .angular-cli.json.
What is the error here ?

Resources