Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native init AwesomeProject SyntaxError : #11384

Closed
MoonTahoe opened this issue Dec 9, 2016 · 29 comments
Closed

react-native init AwesomeProject SyntaxError : #11384

MoonTahoe opened this issue Dec 9, 2016 · 29 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@MoonTahoe
Copy link

react-native init AwesomeProject no longer works for me. It did just a few hours ago. I am working on a macbook pro and I have tried:

  • Restarting
  • Removing and Reinstalling react-native-cli
  • Installing Yarn
  • Different node js versions with nvm

I always get the exact same error:

Last login: Thu Dec  8 17:07:25 on ttys000
192.168.0.104
javac 1.8.0_111
node version v6.9.2
npm version 3.10.9

~ => cd documents
documents => react-native init AwesomeProject
This will walk you through creating a new React Native project in /Users/alexbanks/Documents/AwesomeProject
Using yarn v0.17.10
Installing react-native...
/Users/alexbanks/Documents/AwesomeProject/node_modules/react-native/local-cli/util/Config.js:43
  cwd: string,
     ^
SyntaxError: Unexpected token :
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at loader (/Users/alexbanks/Documents/AwesomeProject/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/alexbanks/Documents/AwesomeProject/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/alexbanks/Documents/AwesomeProject/node_modules/react-native/local-cli/cliEntry.js:13:16)
@SpicyPete
Copy link

👍 Running into the same error. Glad I'm not the only one.

@jiawang1
Copy link

jiawang1 commented Dec 9, 2016

face the same error with react native 0.39.1. seems caused by the syntax of

const Config = {
  get(
    cwd: string,
    defaultConfig?: ConfigT | null,
    pathToConfig?: string | null,
  ): ConfigT {
    let baseConfig;
    // Handle the legacy code path where pathToConfig is unspecified

inside config.js.
looks like typescript...

@bruzenak
Copy link

bruzenak commented Dec 9, 2016

Yep, I'm getting this as well, for basically any run of the react-native cli for a pre-existing project. Started with 0.39.

@matthewconstantine
Copy link

What was the last working version?

@iamtommcc
Copy link

I am also experiencing this issue after trying to upgrade a 0.35.0 project.

0.38.0 appears to be the last working version. 0.39.0 and 0.39.1 both fail whenever trying to run any react-native CLI scripts.

Tried switching between multiple different versions of react-native-cli to no avail.

@noprom
Copy link

noprom commented Dec 9, 2016

Hi, I got the same error, but before it was ok.
Here is my trace error:

➜  Pro react-native init RNGank
This will walk you through creating a new React Native project in /Users/noprom/Documents/Dev/ReactNative/Pro/RNGank
Installing react-native from npm...
Consider installing yarn to make this faster: https://yarnpkg.com



/Users/noprom/Documents/Dev/ReactNative/Pro/RNGank/node_modules/react-native/local-cli/util/Config.js:43
  cwd: string,
     ^
SyntaxError: Unexpected token :
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at loader (/Users/noprom/Documents/Dev/ReactNative/Pro/RNGank/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/noprom/Documents/Dev/ReactNative/Pro/RNGank/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/noprom/Documents/Dev/ReactNative/Pro/RNGank/node_modules/react-native/local-cli/cliEntry.js:13:16)

My react-native version:

➜  Pro react-native -v
react-native-cli: 1.2.0
react-native: n/a - not inside a React Native project directory

My npm version:

➜  Pro npm version
{ npm: '3.10.9',
  ares: '1.10.1-DEV',
  cldr: '30.0.2',
  http_parser: '2.7.0',
  icu: '58.1',
  modules: '51',
  node: '7.2.1',
  openssl: '1.0.2j',
  tz: '2016g',
  unicode: '9.0',
  uv: '1.10.1',
  v8: '5.4.500.44',
  zlib: '1.2.8' }

@dont-see-big-shark
Copy link

 same issue happended herer, i try proxy changes ,reinstall yarn , reinstall node.js, and nothing helps, seems like babel did`t transformed successful.

@rg1220
Copy link

rg1220 commented Dec 9, 2016

+1
I received the same error as well.

@miho7031
Copy link

miho7031 commented Dec 9, 2016

react-native init HelloWorld > Error
react-native init HelloWorld2 > No Error

:(

@gwmccull
Copy link
Contributor

gwmccull commented Dec 9, 2016

I was getting the same error. I hit Cmd-D and clicked Debug JS Remotely. The app refreshed and the syntax error was gone.

If I turn off remote debugging, the error returns.

I already had the debugger window open from another project, but if you don't:
http://localhost:8081/debugger-ui

@rg1220
Copy link

rg1220 commented Dec 9, 2016

FYI - Until this gets resolved, you can use rninit (https://www.npmjs.com/package/rninit) to install using the previous version of react-native. This worked for me:
rninit init mobile --source react-native@0.39.0

@ddpdev
Copy link

ddpdev commented Dec 9, 2016

me too.
react-native 0.39.1 occured but solved

  1. package.json
    "react": "15.3.2",
    "react-addons-shallow-compare": "15.3.2",
    "react-native": "0.38.0",
    ...
  2. npm update
  3. react-native -v
    react-native-cli: 1.3.0
    react-native: 0.38.0
  4. react-native run-ios

** BUILD SUCCEEDED **

...

@amin168
Copy link

amin168 commented Dec 9, 2016

+1,me too
react-native: 0.39.0 and 0.39.1 error
react-native: 0.38.0 is work

@namKolo
Copy link

namKolo commented Dec 9, 2016

I have the same issue with react-native: 0.39.1
screen shot 2016-12-09 at 1 50 45 pm

@sunnylqm
Copy link
Contributor

sunnylqm commented Dec 9, 2016

fallback to 0.38 to resolve this.
react-native init MyProject --version 0.38.0

ping @grabbou

@riyanpratamap
Copy link

riyanpratamap commented Dec 9, 2016

On the same boat as @namKolo
react-native-cli: 1.3.0
react-native: 0.39.1

@namKolo
Copy link

namKolo commented Dec 9, 2016

@Riyanpratama You can roll back to version 0.38.0 as @sunnylqm said. It works for me

@riyanpratamap
Copy link

@namKolo sadly, still had the same problem here.

@namKolo
Copy link

namKolo commented Dec 9, 2016

@Riyanpratama sorry it should be 0.38.1.
image

@riyanpratamap
Copy link

@namKolo created with react-native init fukBS --version 0.38.1 and still got the same error.
screen shot 2016-12-09 at 5 04 38 pm

@namKolo
Copy link

namKolo commented Dec 9, 2016

@Riyanpratama Please run npm uninstall react-native then npm i react-native@0.38
I hope it will help you. But it is just a trick. Hope the bug wil be fixed soon !

@kumarryogeshh
Copy link

@namKolo The trick worked for me 👍

@MoonTahoe
Copy link
Author

I just tried react-native init AwesomeProject again, without the trick... and it worked. I was able to create and run the project on both ios and android.

@bendman
Copy link

bendman commented Dec 9, 2016

This issue seems fairly random. I ended up fixing it by effectively touching node_modules/react-native/local-cli/util/Config.js. I just opened the file up and changed one character, saved, then changed it back, and it started working.

What is more odd is that this caused the packager to work correctly, but watchman watch-del-all && rm -rf node_modules && npm cache clean && npm i didn't fix it.

In my case, I have been on react-native@0.38.1 the whole time, although I have run @0.39 in another project.

@noprom
Copy link

noprom commented Dec 10, 2016

react-native init RNGank --version 0.38.0

This works for me.

@CmST0us
Copy link

CmST0us commented Dec 11, 2016

in file "node_modules/react-native/Libraries/Core/InitializeCore.js"
delete 'use strict';

and it works

@rabidaudio
Copy link

Interestingly, I get this error on an iPhone 4s simulator running 8.1 (and as @gwmccull mentioned it goes away on remote debugging), but not on an iPhone 6 simulator running 10

@damusnet
Copy link
Contributor

@facebook-github-bot duplicate #11389

@facebook-github-bot
Copy link
Contributor

@damusnet tells me this issue is a duplicate of #11389. Let's discuss there, closing this one.

@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Dec 13, 2016
@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests