简体   繁体   English

react-native初始化语法错误​​:意外令牌)

[英]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 我正在尝试使用Windows 10上的ReactNative为Android创建一个简单的应用程序,但是当我打电话时

react-native init AwesomeProject 反应本机AwesomeProject

after installing react-native package I got an error: 安装react-native软件包后,出现错误:

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. 我有NodeJs v5.0.0和npm v3.3.6。

I tried to do steps from here: 我尝试从这里开始:

https://gist.github.com/davidgilbertson/9bee68548037fe00f2a8 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 感觉NodeJ无法理解ES6的语法,但是我不知道为什么

How can I fix this? 我怎样才能解决这个问题?

This is an issue with having non-ASCII characters in your project path. 这是在项目路径中包含非ASCII字符的问题。 When this happens, babel does not normalize the paths for require() calls correctly, and the babel-register functionality fails. 发生这种情况时,babel不能正确规范require()调用的路径,并且babel注册功能将失败。

Long story short, the problem will be fixed with this pull request: https://github.com/facebook/react-native/pull/10154 长话短说,将通过以下拉取请求解决此问题: https : //github.com/facebook/react-native/pull/10154

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

worked for me as it installs latest version of Node.js 为我工作,因为它安装了最新版本的Node.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM