react-native icon indicating copy to clipboard operation
react-native copied to clipboard

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

Open AlexHandy1 opened this issue 10 years ago • 6 comments

The problem

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 final step (see 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 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 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

AlexHandy1 avatar Feb 28 '16 20:02 AlexHandy1

@AlexHandy1 - this seems related to #6298, I think it might be a fixed issue if you try it again :( Sorry

brentvatne avatar Mar 06 '16 22:03 brentvatne

@AlexHandy1 - I mentioned this issue in the one I linked to above, thank you so much for the detailed report, hopefully the folks in that issue can get to the bottom of it so others don't have the problem again. I'm closing this because we're already discussing in the other thread, but this will be a useful reference for those folks.

brentvatne avatar Mar 06 '16 22:03 brentvatne

@martinbigio - reopened because: https://github.com/facebook/react-native/issues/6298#issuecomment-193005739

brentvatne avatar Mar 06 '16 22:03 brentvatne

From https://github.com/facebook/react-native/blob/4130f11b9d8178602427e907cd31cba435baf4e2/local-cli/cli.js#L74?

Although it does look like babel is being run with

require('../packager/babelRegisterOnly')([
  /private-cli\/src/,
  /local-cli/
]);

hzoo avatar Mar 06 '16 22:03 hzoo

The problem is that babel/register doesn't work for the file that includes that directory, on this case local-cli/cli.js. Replacing const for var should fix the issue. I'm not sure why this doesn't repro consistently..

martinbigio avatar Mar 07 '16 01:03 martinbigio

Yep that's what I got from it as well - https://github.com/facebook/react-native/pull/6329

hzoo avatar Mar 07 '16 01:03 hzoo