react-native命令提供syntaxerror

时间:2016-06-13 19:31:12

标签: node.js reactjs react-native

目前正在使用react-native-cli: 1.0.0react-native: 0.26.3

在终端中运行react-native命令会出现此错误。

  

/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229         扔错了;         ^       SyntaxError:/Users/appleuser/package.json:解析JSON时出错 - 意外的输入结束       at Object.parse(native)       在OptionManager.addConfig(/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:225:62)       在OptionManager.findConfigs(/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:442:30)       在OptionManager.init(/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:484:12)       在编译时(/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:112:69)       在装载机(/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:158:14)       at Object.require.extensions。(匿名函数)[as .js](/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:168:7)       在Module.load(module.js:357:32)       在Function.Module._load(module.js:314:12)       在Module.require(module.js:367:17)

任何人都有线索?无法在网上找到任何东西:(

这是我的 package.json

{
  "name": "asklegit",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "ios": "react-native run-ios",
    "android": "react-native run-android"
  },
  "dependencies": {
    "react": "15.0.2",
    "react-native": "0.26.3"
  }
}

1 个答案:

答案 0 :(得分:1)

我不知道在哪种情况下,但似乎有时在用户主目录中创建了一个空的package.json。默认情况下,完全空文件的语法不正确,因此调用应用程序将产生错误。

解决方案是删除空的package.json