yarn create not working like npx - create-react-app

I have a script that does this
npx create-react-app --scripts-version /tmp/tmp.V987BAD2Te/react-scripts.tgz /tmp/tmp.V987BAD2Te/test-app
Its breaking in Windows with message "Path must be a string. Received undefined".
I do not want to upgrade npm for now and so replaced this with
yarn create react-app --scripts-version /tmp/tmp.V987BAD2Te/react-scripts.tgz /tmp/tmp.V987BAD2Te/test-app
But it does not install react-scripts from the temp path.Why

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

Why sould one init a react-native project with npx?

Today I tried to do things differently, and launched a react-native project with npx, and went into troubleshooting issues like react-native command not found, are you sure this is an android project, etc. while things were easier with expo and react-native init.
So I'm wondering, according to you, what are the advantages, what does npx more ?
npm:
npm create-react-app my-app executes the local create-react-app package from your machine, so you first have to install it globally on your system with npm install -g create-react-app.
npx:
If you run npx create-react-app my-app and don’t have create-react-app globally on your system, it will get downloaded and not installed globally.
As you are getting "react-native command not found", first make sure to have react-native cli installed globally. For that,
npm i -g react-native-cli
Then create your react-native project.

How to use Create React App using Yarn 2?

In yarn v1 we initialize create react app using yarn create react-app my-app. How to initialize the same in yan v2.
The above command gives the error
Usage Error: No project found in <<directory>>
$ yarn run <scriptName> ...
Check your yarn version:
yarn --version
If it's below 1.22 you may need to upgrade it to use yarn 2:
npm install -g yarn
You can then create your app:
yarn create react-app my-app
cd my-app
yarn set version berry
yarn
yarn start
This should have your react app up and running using yarn 2. You may want to remove the node_modules folder:
rm -R node_modules
Also, you need the next line on .yarnrc.yml
nodeLinker: "node-modules"
You can use yarn dlx create-react-app my-app. It will work.
There are a lot of changes came with the yarn version2 update.
check this also for additional info: https://dev.to/arcanis/introducing-yarn-2-4eh1

can not install react-native-community/react-native-netinfo

I want to remove "Warning: NetInfo has been extracted from react-native core
and will be removed in a future release.
It can now be installed and imported from '#react-native-community/netinfo'
instead of 'react-native'.
See https://github.com/react-native-community/react-native-netinfo" But when i run command it doesn't work.
npm install --save #react-native-community/netinfo
Because of the # in the name of the package powershell treats it as a variable.
You could fix this by either using cmd.exe or putting the package name in quotes like this: npm install --save "#react-native-community/netinfo"
Actual, #Rik's Answer is correct. i would like to add more..
npm install --save "#react-native-community/netinfo"
run this Command with quotations.
cd android go to your android Project directory
gradlew clean run this to clean your android project
then run either react-native run-android or npx react-native run-android or whatever command you use to start project.

create-react-app only creates package.json, package-lock.json and node_modules

This is my first react app.
I'm working on windows 10, node version 10.15.3, npm version 6.4.1.
This when i execute create-react-app command:
C:\Users\hp\Desktop>npx create-react-app app2
npx: installed 91 in 30.086s
Creating a new React app in C:\Users\hp\Desktop\app2.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
+ react-dom#16.8.6
+ react#16.8.6
+ react-scripts#3.0.1
added 1404 packages from 727 contributors and audited 888973 packages in
237.52s
found 0 vulnerabilities
It just get stuck after this I waited for almost 20 minutes but nothing happened ,no success message or information about commands like npm start is displayed and I have to do ctrl+c to terminate the batch job.
The project folder created contains only package.json, package-lock.json and node_modules and package.json file does not have start,build,test and eject script
Can anyone please help me I am not getting what is wrong here
Try to update the npm package:
npm install -g npm
And then install create react app again:
npm install -g create-react-app
And create the project again
I fixed it in three steps:
npm uninstall -g crete-react-app
yarn global add create-react-app
yarn create react-app my-app
It will work!