【问题标题】:react-native command gives syntaxerrorreact-native 命令给出语法错误
【发布时间】:2016-10-14 08:14:16
【问题描述】:

目前使用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 时出错 - 输入意外结束 在 Object.parse (本机) 在 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) 在 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"
  }
}

【问题讨论】:

  • 请发布您的 package.json
  • @KRONWALLED 那是我的应用程序的 package.json 但为什么错误来自我的全局 package.json
  • 我认为/Users/appleuser/package.json 处有一个空的 package.json。你能看看它,如果它是空的,删除它?
  • @KRONWALLED 甜蜜!谢谢你的工作!
  • @KRONWALLED 不错,您应该将其发布为答案

标签: node.js reactjs react-native


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-14
    • 2019-07-16
    • 1970-01-01
    相关资源
    最近更新 更多