eject command not found in create-react-app -- how to add to package.json? - create-react-app

I get this error after installing create-react-app, and trying to run "npm run eject"
eject: command not found.
How do I edit package.json to run the command I found in the documentation?

I found a work-around: run the script, manually, found in node_modules/react-scripts/scripts/eject.js.
node ./node_modules/react-scripts/scripts/eject.js

facebook's github indicates that the global install of create-react-app would interfere with CRA installation; and so I ran:
npm rm -g create-react-app
as suggested on facebook's github here:
https://github.com/facebook/create-react-app/issues/8088#issuecomment-562189517
(and then reinstall CRA)

You have to install
https://github.com/ramyareye/react-native-eject
yarn add react-native-eject
yarn react-native eject

Instead of npm try with npx
npx react-scripts eject
Above command worked for me.

Related

Error while creating react-native cli project

Error:
Error: Couldn't find the "C:\Users\Admin\AppData\Local\Temp\rncli-init-template-oScLDz\node_modules\react-native\template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template
Screenshot:
I have tried with npm using and it worked.
npx react-native init YourAwesomeProject --npm
After that
I have uninstalled yarn completely. Because you can install libraries using npm. So I have removed the yarn using
npm uninstall -g yarn
You can try:
Remove the global react-native CLI: npm uninstall -g react-native-cli or yarn global remove react-native-cli
And run again npx react-native init YourAwesomeProject
or
Run npx react-native-cli init YourAwesomeProject
Maybe these links can help:
https://github.com/react-native-community/cli#about
How to fix "Can not find module ".../template.config" error in React Native
surely you have your root a file or folder .yarn/ package.json package-lock.json
Remove them and try again rm -rf .yarn/ package.json .yarn/ package-lock.json

How to fix Something went wrong installing the "sharp" module and Cannot find module '../build/Release/sharp.node' in expo

I tried to install expo after I executed the command exp start but I got:
Something went wrong installing the "sharp" module
Cannot find module '../build/Release/sharp.node'.
How can I fix this problem?
I had the same problem and this single line command did the trick.
npm rebuild --verbose sharp
Consult the installation documentation at Common problems.
Find the latest version of sharp and install it.
npm install sharp#0.28.3 --save
This worked for me.
I am not using expo but faced this issue in react native.
All I did is "deleted node_modules/sharp" folder.
run npm install.
fixed the issue.
Maybe you configured npm to ignore installation scripts. In that case delete the sharp module and run:
npm install --ignore-scripts=false
This causes after i updated, npm,angular version.
just try
npm i cordova-res
it solves above problem.
I was facing same issue in mac when I update my developer tools using xcode-select install then node project stop working on local
sudo rm -rf /usr/local/Cellar/python3.8
sudo rm -rf /usr/local/Cellar/python3.9
rm yarn.lock
rm package-lock.json
rm -rf node_modules
brew upgrade
yarn install
worked for me
If anyone has this problem and other solutions didn't solve it. Try to uninstall vips globally, it worked for me.
npm -g uninstall libvips
brew uninstall vips
Then:
yarn clean
yarn install
gatsby develop
if trying some quick command fixes don't work you can try rebuilding the node_modules.
Delete the whole node_modules folder and run npm install
npm install
Upgrading of gatsby-transformer-sharp helped me in my case.
You may need to completely reinstall expo-cli package.
yarn global remove expo-cli
yarn global add expo-cli
OR
npm uninstall expo-cli -g
npm install expo-cli -g
(If you don't have expo-cli installed globally, remove global / -f flags)

Install Expo package directly from Github

For some reason the Expo team is not updating their packages on npm and I need to install directly from their Github repo. The packages are in the packages/package-name folders on the main Expo repository.
I put "expo-blur": "expo/expo packages/expo-blur" in package.json, but that also just uses the npm release. I asked a similar question here: https://forums.expo.io/t/recommended-way-for-using-expo-packages-straight-from-github/22022.
What do I need to put in package.json so that it uses the code from here: https://github.com/expo/expo/tree/master/packages/expo-blur ?
No you can't. You will end up having it undefined in your package.json file like this:
The command was:
npm install Teknasyon-Teknoloji/desk360-react-native-sdk#1.0.0 --save
I tried:
npx expo install Teknasyon-Teknoloji/desk360-react-native-sdk#1.0.0
So the correct way is:
Switch to bare workflow if you are in managed workflow:
npx expo prebuild
Then follow the rest of the steps from the package docs. So I then ran:
npm install Teknasyon-Teknoloji/desk360-react-native-sdk#1.0.0 --save
then cd ios, pod install ...etc.

npm install -g not working while uninstalling react-native-cli?

I am trying to uninstall the "react-native-cli" which I use for react-native projects! but I am not able to do so!
My environment is mac.
Here is what i have done so far!
Whether I type npm uninstall -g react-native-cli or sudo npm uninstall -g react-native-cli.
The terminal shows: up to date in 0.041s
When I type react-native init projectName, it still creates the project.
I think the command react-native init should not to work.
Anyone knows how to uninstall react-native-cli ?
Thanks in advance.
SOLUTION ONE !
not fully sure this will work! but try updating your npm first by doing
npm install npm
and after that try uninstalling the cli if that does not work then
SOLUTION TWO !
Here is another go around to solve the issue its a bit manual way
1: First run this
npm list -g
this will show the list of installed packages in your user folder
then check . using command+f if there is react-native-cil there
then do this
open /usr/local/lib/node_modules
This will open the root installed packages and you can manually find and delete the react-native-cli like this
If you are using yarn. You can do yarn global list then check that if any package contains react-native. Then run yarn global remove <package> to remove that package.
ex:
yarn global remove #react-native-community/cli
You can uninstall react native CLI using:
npm uninstall -g react-native-cli

React Native: Command `run-ios` unrecognized

I have two different ReactNative-Projects:
a) a project from januar 2016
b) a complete new react-native project
from now (march 20th 2016)
Within the new project the cli tool of react-native contains the command "run-ios" next two "run-android", but not on the older project from januar 2016. On the older one there is not "run-ios" command available:
$ react-native run-ios
Command `run-ios` unrecognized
Usage: react-native <command>
I already ran "react-native upgrade" without any issues.
How can i get the command "run-ios" also in older projects?
Just update the version of react native in your project with the following command:
$> npm install --save react-native#latest
What caused this for me was running npm install --save [package] when actually the system has previously been using yarn instead of npm.
To solve this I just deleted the node_modules folder and ran: yarn install and after that react-native run-ios (or android) works fine.
$ react-native run-ios
If you get this kinda error:
"Command run-ios unrecognized. Make sure that you have run npm
install and that you are inside a react-native project".
In terminal, make sure you are inside a react-native project directory.
Execute this cmd:
$ react-native -v
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory
$ npm update
$ react-native -v
react-native-cli: 2.0.1
react-native: 0.44.0
$ react-native run-ios
This may sound silly, but make sure you cd to your project directory. If that fails then perform the npm install in the other answers.
I found a solution that works for me.
Update the version of react native in your project:
npm install --save react-native#latest
then upgrade your npm version
npm i npm#latest -g
then move directory folder 1 level up, type
cd ..
make a new react-native installation folder
react-native init NewProject
then go to your project folder(NewProject), after that
react-native run-ios
should work fine.
This happens when the project has an older version of react native. You can update the react version or for people who do not want to upgrade, just open the .xcodeproj file in iOS dir and hit the play button in the Xcode.
In my case, it was an issue with the package.json file. I deleted a section during a test. I recover a previous file with the deleted section and everything was working again.
this works for me
sudo npm install -g react-native-cli --force
then
react-native run-ios
In my case, I am using monorepo with multiple packages in a single repo. I solved this error by
Deleting the packages/myapp/node_modules
running yarn install from the project root. Not inside packages
its solved. Now can run yarn ios or yarn android commands
Note:
For autolinking libraries you need to have all of your dependencies in root package.json file also copied to packages/myapp/package.json file. See https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-use-autolinking-in-a-monorepo
Example:
"dependencies": {
"#react-native-community/datetimepicker": "^3.5.2",
"#react-native-community/masked-view": "^0.1.11",
"#react-navigation/native": "^5.9.4",
"#react-navigation/stack": "^5.14.5",
"#reduxjs/toolkit": "^1.6.0",
"#voximplant/react-native-foreground-service": "^2.0.0",
"axios": "^0.21.1",
"babel-eslint": "^10.0.3",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
...
...
but make sure NOT TO COPY
"react-native-cli": "^any version",
otherwise react-native-cli would collide and you will continue to see error like
Command `run-android` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
error Command failed with exit code 1.
or
Command `run-ios` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
error Command failed with exit code 1.
I created a brand new react-native project using
$ react-native init projectName
and ran from root of the project
$ react-native run-ios
Everything worked fine and iOS simulator fired up as expected.
Than I installed prop-types node module using npm install prop-types --save. Re-ran $ react-native run-ios and ran into this error Command run-ios unrecognized
Solution:
From the root of my project, removed node_module and re-installed modules using npm. Commands below
$ rm -rf node_modules/
$ npm install
$ react-native run-ios
For me, Xcode was already running.
Close the Xcode and then in the terminal, make sure you are inside a react-native project directory and then execute react-native run-ios command
For me, the only thing that worked was to checkout again my repository from zero and run:
npm install -g react-native-cli yarn
yarn
git submodule update --init --recursive
What caused this for me was running npm install --save axios when actually the system was previously using yarn instead of npm.
To solve this, instead of deleting the node_modules folder, which can lead to more problems, and if you prefer to run npm anyway or don't have a preference either way, the error should have instructed for you to run npm install. If you literally follow those instructions, you will be able to run: react-native run-ios afterwards.
I also fell in this error and the reason was
I was using yarn link command in wrong folder
Delete the node-modules. Its because the packages are not installed.
rm -rf node_modules
npm install
then run your project
react-native run-ios