Viacheslav Yankov
Viacheslav Yankov

Reputation: 1008

react-native init syntaxerror:unexpected token )

I am trying to create a simple app for Android with ReactNative on Windows 10, but when i call

react-native init AwesomeProject

after installing react-native package I got an error:

C:\Users\Вячеслав\Documents\ReactNative>react-native init AwesomeProject2
This will walk you through creating a new React Native project in C:\Users\Вячеслав\Documents\ReactNative\AwesomeProject2
Installing react-native package from npm...
C:\Users\Вячеслав\Documents\ReactNative\AwesomeProject2\node_modules\react-native\packager\react-packager\src\Server\index.js:199
      );
      ^

SyntaxError: Unexpected token )
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Module._extensions..js (module.js:432:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Users\Вячеслав\Documents\ReactNative\AwesomeProject2\node_modules\babel-core\lib\api\register\node.js:214:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (C:\Users\Вячесла\Documents\ReactNative\AwesomeProject
2\node_modules\react-native\packager\react-packager\index.js:16:14)
    at Module._compile (module.js:425:26)

I have NodeJs v5.0.0 and npm v3.3.6.

I tried to do steps from here:

https://gist.github.com/davidgilbertson/9bee68548037fe00f2a8

but they did not help me:(((

a feeling that NodeJs can not understand the syntax of ES6, but I don't know why

How can I fix this?

Upvotes: 2

Views: 4940

Answers (2)

Paresh Thakor
Paresh Thakor

Reputation: 1835

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

worked for me as it installs latest version of Node.js

Upvotes: 5

Eric Rozell
Eric Rozell

Reputation: 146

This is an issue with having non-ASCII characters in your project path. When this happens, babel does not normalize the paths for require() calls correctly, and the babel-register functionality fails.

Long story short, the problem will be fixed with this pull request: https://github.com/facebook/react-native/pull/10154

Upvotes: 1

Related Questions