27
votes

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
2
@raju-gujarati can you detail more about why you've added a bounty to this? What is your current set up? Are you using RN version 0.20 as referenced in the question? - Jason Gaare
My setup Macbook Pro 2012 - OS X 10.12.6 Sierra Xcode (v8.3) Node (v8.4.0) and NVM (0.31.0) React Native (v0.47.0) - Raju yourPepe
usually it takes for a few minutes to build react-packager . But for my case, it takes infinitely long. I don't know what is going on - Raju yourPepe
Why are you using such an old react-native package? Have you tried upgrading it? Sorry just see this was already fixed - sandino
This might help you to solve your issue: stackoverflow.com/a/48431161/690771 - Santosh Kumar

2 Answers

1
votes

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.

0
votes

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.