Cannot start ReactNativeProject - react-native

I followed the tutorial in the link here https://facebook.github.io/react-native/docs/getting-started.html#content . As it turns out, npm 5 is not supported yet. I tried installing npm 4 but, it is not working either. Stuck in the first page of the tutorial, when I run npm start, I am getting a bunch of errors too. Literally stuck, nowhere else to turn. Before voting down the question, kindly note that I am a mobile developer working with andorid and Ios having no previous knowledge about web technologies. Thanks
These are the steps I followed
npm install -g create-react-native-app
It was successfull, then,
create-react-native-app AwesomeProject
for this line, I got the following error
*******************************************************************************
ERROR: npm 5 is not supported yet
*******************************************************************************
It looks like you're using npm 5 which was recently released.
Create React Native App doesn't work with npm 5 yet, unfortunately. We
recommend using npm 4 or yarn until some bugs are resolved.
You can follow the known issues with npm 5 at:
https://github.com/npm/npm/issues/16991
*******************************************************************************
Then I ran the command
cd AwesomeProject
Afterwards I ran
npm start
for which I got the error
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jayakrishnan/.npm/_logs/2017-07-25T08_13_06_277Z-debug.log
I tried using Yarn But didnt work

npm i -g npm#4.6.1 - then install create-react-native-app again and create a project.

Solution with Yarn:
First install Yarn
yarn global add create-react-native-app
cd AwesomeProject
yarn start

npm install -g npm#4 Use this to downgrade, Also use sudo with the commands, sometime it does give permission to write error and skips the installation

Try putting more information about the error so we can help, or steps to reproduce it.
One thing to try is to instead of using npm, use yarn. Install yarn with brew install yarn if you are on mac and do the same steps in the getting-started guide, except for use yarn run ios to start app in ios simulator.
I just tried with a fresh setup that this is working perfectly fine.
Reference to yarn https://yarnpkg.com/en/

Related

Cannot find module ‘#expo/metro-config’ when trying to start the project with expo cli >= 4.8.0

I recently tried to launch my project on a new computer. I downloaded the source code from its repository and ran npm install to get all the needed packages.
However, when I run npm start or expo start:web, I get the error:
Cannot find module '#expo/metro-config'
I ran npm install #expo/metro-config and the install run without issue, but I still get the “Cannot find module '#expo/metro-config'” error.
The only post I saw regarding this error recommends editing the metro.config.js but I do not use one.
I am on SDK 42, and the project launches fine on my other computer. Any idea what is happening?
FYI, I use to perform this whole operation without any issue until now.
UPDATE:
I ran npm install -g #expo/metro-config and now I get the error Cannot find module 'resolve-from'
So it looks like maybe running npm install -g expo-cli doesn't actually install all the necessary packages? Could it be the issue?
I managed to make it "work" (get other missing packages errors down the line) by reverting to expo-cli 4.7.3. Anything from 4.8.0 and above will cause the error.
Something else is that on a fresh npm install, after running npm install -g expo-cli, if I try to create a project with expo init, I will get the error Error: Cannot find module 'kleur'. Running npm install kleur fix it, but maybe that's also a clue.

On Mac M1, can't run scripts in package.json: - sh: <dependency>: command not found

I just got a Mac Mini M1 for personal use, and I'm trying to run a preexisting React app. I installed nodejs and npm successfully, and running npm install does add the node_modules folder correctly as far as I can tell; but whenever I run npm start or npm run <script>, I get an error. It seems that npm can't access any of the project's dependencies. I've tried this using the rosetta terminal as well with the same results.
For an example, I initialized a new React project with npx create-react-app test_app, then cded into it and ran npm start. I got:
test_repo#0.1.0 start
> react-scripts start
sh: react-scripts: command not found
How do I get these commands to run properly and launch the app?
Here's what I'm using for node and npm:
➜ test_repo npm -v
7.6.0
➜ test_repo node -v
v15.11.0
I found a (very) hacky solution for now. I'm no expert with npm, but what I discovered is that npm scripts refer to dependencies indirectly - for example, having a command that says
"test": "jest"
tells npm to look in node_modules/.bin for a file called jest and to run that.
the issue is something to do with npm understanding this. But it's possible to get around that by putting the address of each dependency in the script, for example:
"test" "node_modules/.bin/jest"
I was able to get things to build this way. If someone comes along with a better answer, please show me up :P

RN Expo issue - Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app

I am using react native and Expo. I am unable to build new app because after I use expo init appName it shows the following error.
Heres the full message:
📦 Using npm to install packages. You can pass --yarn to use Yarn instead.
√ Downloaded and extracted project files.
× Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app.
✅ Your project is ready!
To run your project, navigate to the directory and run one of the following npm commands.
- cd Scanner
- npm start # you can open iOS, Android, or web from here, or run them directly with the commands below.
- npm run android
- npm run ios # requires an iOS device or macOS for access to an iOS simulator
- npm run web
I tried multiple times to create a blank project, also tried npm install to install failed/not downloaded libraries and continue after failure but it showed another error:
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
also tried npm cache verify that showed cache is ok Content verified: 3562 (252580364 bytes).
So, How can I solve this issue?
Problems related to npm installation are very common If you do any mistake in early installation, but is avoided. Learn more about npm tree.
Steps worked for me are :
npm cache clean --force
npm cache verify
npm -g uninstall expo-cli --save
npm install expo-cli --global
expo init app-name
cd app-name
npm start
Always run as administrator if working on Windows and in root directory.
The solutions above didn't work for me but if you use 'npm install' in the directory of the app you get a clue that you shuold try 'npm install --force'
err message
You should have all these files folders and files at the start of the project otherwise not all the dependencies have been installed which is why we were getting the problem.folder structure
After you have added --force to npm install you have all the dependencies installed. Now you can run the app with npm start.
Unfortunately, all the solutions described above didn't work on my machine...
Here is my latest solution for this problem...
This worked 100% on my machine...
Use npm i -g expo-cli
This will automatically add the required packages and also remove the unnecessary ones.
Yes, surely, you don't need to uninstall and re-install it again.
Just follow my steps.
And, you can create your expo project using expo init.
I hope my solution will help you out from this annoying problem....
I just did npm install and it worked for me, but I had do that every time I create a new expo project.
I also encountered this problem, and finally found that it was the problem of react native cli,I installed the latest version of react native cli,Expo is back to normal
This Error is regarding to the git account. expos need a git account to setup react native project
If you are using windows you need to install git in your local PC
after that open your Terminal and type this command
git config --global user.name "your_username"
git config --global user.email "your_email_address#example.com"
after that clone any github project to your local computer. it will ask to login to Github
after all these steps try expo init <projectname>
The simple way to settle that error is by using "expo-cli init app-name" instead of "expo init app-name".
I tried and worked perfectly for me. Hope it will help you guys.
i have faced a similar problem and running yarn set version 1.22.1 fix it
Run the Command Prompt as an administrator. And run the following command:
npx create-expo-app AwesomeProject

`npx create-nuxt-app <project name>` not working: MacOSX

I use a MacOS High Sierra. For anyone with experience with Nuxt.js, the command
npx create-nuxt-app <project-name> has not worked for me at all!
I consistently come across errors from npm saying I need to update my dependencies. I first tried updating each dependency using npm outdated (check for outdated packages) and
npm update <pkg name>. This did not work.
I also uninstalled and reinstalled node and npm and tired the above (and below processes). Still did not work.
No matter what I do, the Terminal keeps saying my core-js needed to be updated so I did that (I tried both npm i core-js and npm i core-js ) - they did not work.
To update the npm dependencies, I used the command npm install -g npm-check-updates followed by ncu -u, and then tried both npm update and npm install. Nothing has worked so far.
Lastly, I've tried creating a package.json since npm complained that I had no package.json so I created one using npm init and following the instructions to commit the file(s) created. Still, nothing after running npx create-nuxt-app <project-name>.
What is happening? Has anyone experienced this issue? I really love Nuxt.js and I've tried this for an entire day but I'm giving up on using NuxtJS.
EDIT: I managed to solve part of my problem by creating a Nuxt app from scratch. However, I get the following errors:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nuxt-app#2.11.0 dev:nuxt
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nuxt-app#2.11.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
There are many solution based on your problem. Sharing a simple one, if you have npm installed then execute below command to install npx:
npm install -g npx
you can find all others solution from here
and My suggestions are:
As i saw your description, package.json not created. definitely something wrong for creation of the project, it may cause the read write problem of files into disk. or you have created the project into subdirectory but trying to run the project from parent directory. initially many peoples doing this practice to create scratch project. by the way create a separate directory and then run npx create-nuxt-app. no need to give project name and pass the phase when prompt to create project in same directory. so then i think problem will solved
I fixed the issue! It worked when I created a new directory altogether (the next day) and reran npx create-nuxt-app <new-app>. Get started, build for production, and tests ran perfectly.

Can't run "npm install expo-cli --global"

I am a newbie in all this stuff. Hope for your understanding.
Let me clarify the issue:
I am trying to start react native app through expo cli. So tried to start npm install expo-cli --global to install npm globally. I got these errors:
Screen_1
Screen_2
It also says that I lack permissions to access it. How can I allow permissions?
Even when I try to start it locally I got the same issue. Your help is appreciated.
although this solution is not the best and the safest solution exists, this worked for me and that make sense because all the problem we had with the errors is the permission problems. so you can use this command and ignore those permission problems :
sudo npm install expo-cli -g --unsafe-perm
I was having the same problem with npm install -g expo-cli, having "MODULE_NOT_FOUND",
I installed yarm with brew, just in case you do not already have it:
brew install yarn
and then use:
yarn global add expo-cli
to create a project you can:
expo init nameOfTheNewProject
and choose a template in the console.
Finally run the project with
yarn start
Let me know if it works for you!
You did not mention which os. This answer working for any operating system (ubuntu in my case)
I'm also getting permission errors when running
sudo npm install --global expo-cli
Which I don't really how this can happen - as this also happens for the superuser!
For me it works when I install the client locally into the project
cd <new-project-dir>
npm init # init npm project
npm install expo-cli
Now you can use the client in this project like this:
npx expo-cli # e.g. npx expo-cli init <project-name>
npm cache clean --force
This will solve the issue
Try using npm install -g expo-cli#3.5.0 this worked for me, it may work for you.
You can try this command:
npm install -g expo-cli
or,
yarn global add expo-cli
You have to run the command as administrator from a command prompt on windows and not bash. Had me stumpt for bloody ages!
You need administrator privilege. So when you open command line interface, just right click and run as administrator
This will solve the problem
I guess, this issue comes from permission or node version , if you get this error when the node module is being refreshed ---> This is definitely a permission issue. Disable your Antiviruses or change permission manually check this as well.
First run npm cache verify, then run sudo npm install --global expo-cli.
Did work for me indeed after trying so much.
Follow the steps
First, run npm cache verify.
Open Windows PowerShell as administrator and run npm install expo-cli
--global --no-optional command.
npm cache clean --force then npm install --unsafe-perm -g expo-cli
It is likely you do not have the permissions to access this file as the current user.
The best way to solve this problem is to reinstall npm with a node version manager.And you don't need to remove your current version.
About node version manager
use nvm or n with OSX or Linux
use nodist or nvm-windows with windows
Upgrade Node version to +10
Then do
sudo npm install expo-cli -g
This worked for me. I hope this would solve your problem!
sudo npm install expo-cli -g --unsafe-perm=true --allow-root
If any of the solutions above result in success, please follow the steps below:
Uninstall Node.js
Restart your pc/mac
Download latest version of the Node.js (https://nodejs.org/en/)
Open cmd as admin mode or use "sudo" before the command line on Mac.
npm install expo-cli --global
I hope it can help
In my case, I deleted two files then everything worked. The two files are in this path: C:\Users\{Username}\AppData\Roaming\npm under the names 'expo.ps1' and 'expo-cli.ps1'
Then run:
npm i -g expo-cli
re-install node.js, it works for me
First update Node.js to the latest stable version and then again try to install expo ad clean before expo folders that are being created in below location
C:\Users\{{computer_username}}\AppData\Roaming\npm
If it's throwing error in visual studio code, try from cmd, was facing same error but solved through this way
npm install -g expo-cli
try going into windows resource monitor and terminating adb.exe (android resource bridge). This worked for me after searching for solutions for days. I tried this after verifying cache, clearing cache, you name it.
As a Debian 10 buster user I got the same permission error while using this command: sudo npm install expo-cli --global.
The problem was solved by installing expo-cli with yarn package manager and the command below: sudo yarn global add expo-cli.
For Windows User :-
Open your Powershell and type:
npm install expo-cli --global
This worked for me after trying and reasearching for hours.
Note:Don't Use cmd or any other terminal and also don't type npm install expo-cli -g as it is written in the react native docs. It would always show up an npm error.
For windows
Follow these steps carefully
open the command prompt and run it as administrator.
recommended npm uninstall --global expo-cli.
run the command npm cache clean --force.
run the command npm cache verify .
now run the command npm install --global expo-cli
dont run command like npm i -g expo-cli or npm install -g expo-cli.
7.Make sure you run the command mentioned in the 4th step ONLY.
thankyou.
I had this problem in Windows 10, to be able to install the latest version (I had no choice since it broke the current one). I had to install the latest version of Python (3.8.0) and then run npm install --global --production windows-build-tools as an administrator, then I was able to run again: npm install expo-cli --global to install the version 3.8.0 of the expo-cli
Here is the solution and 100% working. I am working with Windows and not sure abut Linux.
Open cmd and
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
then press yes
Now run the command to start your project
npm install -g expo-cli
I had previously removed Expo from my Windows machine and encountered this error whilst trying to reinstall. Reading the error message solved the problem.
npm i expo-cli -g --legacy-peer-deps
Using this command in 'PowerShell' installed expo successfully.
If anyone else has this problem here is my fix, go to Finder, in the input field (search box) type in /usr/local/lib then press CMD + SHIFT + G press the OK button or whatever pops up, then CMD + SHIFT + . and delete the NVM file i deleted the expo folder too. Then go to this link https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
follow the instructions and install brew, node, etc. Last step go to your terminal and type sudo npm install expo-cli --global
First: I upgraded my mac version 10.13 to 10.15
Then I downloaded homebrew, Watchman, Git and Node.js
Finally I ran this command sudo npm install --global expo-cli --legacy-peer-deps
If you have any further questions check the docs out: https://docs.expo.dev/get-started/installation/
Sometime, I use npm not work.
I try a lots times run with npm but fail for expo cli.
Please try yarn global add expo-cli
It wills save your time ^^.
I was trying to install expo-cli with my company npm registry configured.
I've created 2 differents profiles using npmrc and using the profile with https://registry.npmjs.org/ solved the issue.