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

Errors with run-android on OSX Yosemite

Open slooker opened this issue 11 years ago • 9 comments

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

slooker avatar Nov 19 '15 00:11 slooker

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)

sunnylqm avatar Nov 19 '15 00:11 sunnylqm

Nope.

slooker ~/code $ node -v
v5.1.0
slooker ~/code $ which node
/Users/slooker/.nvm/versions/node/v5.1.0/bin/node

slooker avatar Nov 19 '15 00:11 slooker

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?

sunnylqm avatar Nov 19 '15 02:11 sunnylqm

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.

screenshot 2015-11-18 18 30 09

slooker avatar Nov 19 '15 02:11 slooker

It seems that somehow the packager was using the outdated node.

sunnylqm avatar Nov 19 '15 02:11 sunnylqm

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?

slooker avatar Nov 19 '15 02:11 slooker

I am not familar with nvm. So my solution is to not use nvm, if possible :(

sunnylqm avatar Nov 19 '15 02:11 sunnylqm

That's not a very good solution. :/

slooker avatar Nov 19 '15 02:11 slooker

nvm alias default 5.1.0 makes it work.

slooker avatar Nov 19 '15 05:11 slooker