Errors with run-android on OSX Yosemite
I'm running node v5.1.0. I'm running the most recent react-native-cli. My process for project creation was like so:
npm install -g react-native-cli
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
This is the error I get:
/Users/slooker/code/AwesomeProject/node_modules/react-native/local-cli/cli.js:56
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
Process terminated. Press <enter> to close the window
CHECK your node version by node -v
It seems that you are actually running a node version < 4.0(maybe installed by brew or some other way and haven't been upgraded to 5.1.0 properly)
Nope.
slooker ~/code $ node -v
v5.1.0
slooker ~/code $ which node
/Users/slooker/.nvm/versions/node/v5.1.0/bin/node
I have checked 5.1.0 on El Capitan just now, no problem at run-android.
You are using nvm and running node -v under "code" directory, while your project directory is "AwesomeProject". Maybe you should check node version there?
I'm running yosemite and under AwesomeProject it's still 5.1.0.
The window in the foreground is the one that automatically opened up when I ran "react-native run-android" in the background.
It seems that somehow the packager was using the outdated node.
I deleted the app completely, verified I was on node 5.1.0, redid the react-native init AwesomeProject, and tried it again and I still get the same problem. Any suggestions for how to fix that?
I am not familar with nvm. So my solution is to not use nvm, if possible :(
That's not a very good solution. :/
nvm alias default 5.1.0 makes it work.