react-native run-ios packager build error - AwesomeProject quick start - react-native

The problem
Open react native issue here
I have researched this error extensively (~ 2days dev time) but somehow still no resolution - I have run previous React Native setups fine and thought this might resolve as a final step (see the end of issue).
In short, when I run react-native run-ios from example "AwesomeProject" directory I get the below error in the React Packager launchPackager.command window.
~/AwesomeProject2/node_modules/react-native/packager ~
/Users/alexanderhandy/AwesomeProject2/node_modules/react-native/local-cli/cli.js:74
const setupEnvScript = /^win/.test(process.platform)
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
My setup
Macbook Pro 2012 - OS X 10.11 El Capitan
Xcode (v7.2.1)
Node (v5.7.0) and NVM (0.31.0)
React Native (v0.20.0)
Steps
Upgraded laptop to El Capitan (as per version above) - hadn't used much for last 6 months so was coming back to run some setup
Attempted react native setup and got an error running homebrew when tried to install. Found some unexpected changes to many files when ran git status -- so went into the relevant usr/local homebrew directory and ran git fetch; git reset --hard origin/master
Updated Xcode to over v7 (as per version above)
Installed nvm and latest node to address error warning from Node - note: for some reason have to run . ~/.nvm/nvm.sh in terminal to get nvm working, when I don't v5.7.0 becomes v0.12.4. I have double-checked node is v5.7.0 when error runs
Finally got through to actually building an app when ran react-native init AwesomeProject which completed but hanged for like 10 mins
Ran react-native run-ios and got error and tried to add source ~/.bash_profile to node_modules/react-native/packager/react-native-xcode.sh as suggested here
Considered going back to Ionic so went through their setup again and that wouldn't work either
Tried not to throw my laptop out the window

I had the same problem when creating my project from react-native init command. What I did to get a successful build was do npm install babel and then finally do react-native run-ios. Hope this helps.

this is the issue of Community CLI
kindly add it properly else remove it from your package.json and run your project from xcode it would help
(https://github.com/react-native-community/cli)
when you start a react native project with react-native init MyProject it doesn't add few things globally so we use npx react-native init MyProject.

Related

Can't run React Native on Catalina

When I try to run a React Native App in the simulator, i get this:
Error: Could not find iPhone X simulator
at resolve (/Users/hugh/code/iosapps/Test/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
at new Promise (<anonymous>)
at runOnSimulator (/Users/hugh/code/iosapps/Test/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
at Object.runIOS [as func] (/Users/hugh/code/iosapps/Test/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
at Promise.resolve.then (/Users/hugh/code/iosapps/Test/node_modules/react-native/local-cli/cliEntry.js:117:22)
The simulator exsists on my system, but React Native can't find it.
Please help me!
Did not install React Native properly.
This one drives me nuts too, I get it every time I update my OS. Your version of Xcode might be conflicting with your RN version.
Try a combo of some of these things:
Before you do ANYTHING make sure you have a working backup of your project
upgrade react native project version (if possible) react-native upgrade
remove node_modules and reinstall rm -rf node_modules then npm i or yarn
remove your .lock files and run npm i or yarn
best of luck

React Native 0.60.4 detox postinstall.js install error

Not able to install detox by npm install or yarn.
yarn add --dev detox will fail out in the postbuild.js`
This question is in response to wix/detox's policy regarding issue tracking:
https://github.com/wix/Detox/issues/1523
Followed the latest tutorial to get started with detox.
react-native init example // (0.60.4)
brew update
brew tap wix/brew
brew install applesimutils
yarn global add detox-cli // you shouldn't need this
yarn add --dev detox // add this package in /example app
Installing detox will exit out with a childprocess error.
Error:
Command Failed: <YOUR_PROJECT_PATH>/node_modules/detox/scripts/build_framework.ios.sh
at checkExecSyncError (child_process.js:629:11)
at Object.execFileSync (child_process.js:647:13)
at Object.<anonymous> (<YOUR_PROJECT_PATH>/node_modules/detox/scripts/postinstall.js:2:27)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Followed their guide here:
https://github.com/wix/Detox/blob/master/docs/Introduction.GettingStarted.md
UPDATE: See the solution below, was able to get detox installed without an issue.
The detox version that was previously installed required the Legacy Build System
How to upgrade correctly:
Remove ~/Library/Detox/
Remove ~/Library/Developer/Xcode/DerivedData/*
yarn add -D detox // installs without and issue
How did this issue occur:
If you have a previous version of Detox installed which relied on an earlier Xcode you will get a conflict between Legacy & New Build System.
Detox will then look at your ~/Library/Detox data and fail to build due to New Build System being selected as default
I resolved this install error by doing the following:
In xcode 10.3 go into File > Workspace Settings
Under Shared Workspace Settings select Legacy Build System
Re-install detox (it will not use the legacy build and not error out)

"Unexpected token import" as error when creating new react-native project

I am creating a new react-native project using :
react-native init {proj_name}
But I am getting the following error.
D:\Reactnative\Project\{proj_name}\node_modules\react-native\local-cli\cliEntry.js:30
import type {CommandT} from './commands';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Module._compile (D:\Reactnative\Project\Learnwizz\node_modules\pirates\lib\index.js:91:24)
at Module._extensions..js (module.js:654:10)
at Object.newLoader [as .js] (D:\Reactnative\Project\Learnwizz\node_modules\pirates\lib\index.js:96:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
This is a known bug right now with react-native 0.56 when running on Windows (see here and here).
Until it is fixed, you can work around the issue by explicitly specifying an older version of react-native when running react-native init. E.g.
react-native init {proj_name} --version react-native#0.55.4
EDIT: As a temporary workaround, you can init your project with the previous version of RN using react-native init --version="0.55.4" {projectName}
I'm also running into this exact error today. I just now noticed react-native init is now using react-native 0.56 which was just release a few hours ago I believe.
This might give you some troubleshooting ideas.
Currently I am getting Exception in latest version that is 0.56 (React Native) and not able to run the code in emulator, However I have downgraded React native version to 0.55.4, then it is working for me..
Run Below line of command :
react-native init {project_name} --version react-native#0.55.4
Yes, with new version of react-native , typescript code in react-cli has some issue , but don't worry
go to app folder
hit command
npm uninstall react-native --save
npm install react-native#0.55.4 --save
will solve your problem !!
in windows 10 update node.js to version 14.18.1
https://nodejs.org/dist/v14.18.1/node-v14.18.1-x64.msi

Cannot running successful built react-native project on iOS simulator error

I'm programming an APP using react-native, but after I pulled from github this morning, it turned out that I couldn't run it anymore. The logs in the command line are as follows:
** BUILD SUCCEEDED **
The following commands produced analyzer issues:
Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)
Logs in "react-native start" command line are as follows:
error: bundling failed: TypeError: Cannot read property 'bindings' of null
at Scope.moveBindingTo (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/scope/index.js:978:13)
at BlockScoping.updateScopeInfo (/Users/martin/Desktop/ble-server/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
at BlockScoping.run (/Users/martin/Desktop/ble-server/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
at PluginPass.BlockStatementSwitchStatementProgram (/Users/martin/Desktop/ble-server/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
at newFn (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/visitors.js:237:21)
at NodePath._call (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/path/context.js:65:20)
at NodePath.call (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/path/context.js:100:12)
at TraversalContext.visitQueue (/Users/martin/Desktop/ble-server/node_modules/#babel/traverse/lib/context.js:142:16)
BUNDLE [ios, dev] ../../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
How could I run it again, it seems that there are no issues with codes.
Please run command first:
npm start
and then
react-native run-ios
You have probably updated react-native improperly please check the documentation.
You may have used npm audit fix which updates react-native.
To fix the problem you can downgrade the react-native version of the app with
npm install react-native#x.x.x"
Then re-compile project with
react-native run-ios"
And don't forget to restart the bundler as well with
react-native start
Then, if you still want to upgrade the react-native version you can use
react-native-git-upgrade

The command 'react-native run-android' shows up errors although there is an emulator running (or device connected)

I started a react-native project with 'react-native init' and was created without errors, however, when I used the command 'react-native run-android' in the project directory this is what I got:
throw er
^
Error: EIO: i/o error, read
at Object.fs.readSync (fs.js:675:18)
at Object.readSync (D:\myProjects\react-native\ReactTodoApp\node_modules\graceful-fs\polyfills.js:138:28)
at tryReadSync (fs.js:540:20)
at Object.fs.readFileSync (fs.js:575:19)
at Object.Module._extensions..js (module.js:645:20)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18).
The same error appears although that android emulator is running or an android device connected, all the same.
I need to know what is the solution to this.
I am using react-native 0.50.3, react-native-cli 2.0.1.
Seems like a Node related error.
Try restarting Node server. Node cannot read polyfills.js. This can happen if multiple command instances are running in same directory at same time.
Sometimes cleaning cache works
Updating or reinstalling react native is a suggested fix.
You could uninstall react-native and then use the following command:
npm install react#reactversion --save.
Note (reactversion) is your desired version you want to have.
You could also just try reinstalling it as:
npm install react --save
Or upgrade with:
npm update react-native