React Native iOS:无法使用npm和yarn构建错误消息

时间:2018-12-03 15:10:19

标签: react-native react-native-ios detox

我是使用React本机(ios)的新手。使用ios应用程序创建第一个框架。我正在使用udemy课程(但我认为还不够清楚),我设置了package.json并尝试在Visual Studio IDE中构建它。

我使用的命令是

npm run test:e2e:build

,但收到错误消息。

所以我决定使用yarn查看是否可以构建该项目

yarn run test:e2e:build  

这也失败了。

问题:

  1. 我在做什么错了?
  2. 我该如何解决。

错误消息

enter image description here

Package.json

{
  "name": "boatconnect",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "ios": "react-native run-ios",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "test:e2e":"boatconnect test",
    "test:e2e:build":"boatconnect build"
  },
  "dependencies": {
    "react": "16.6.1",
    "react-native": "0.57.7"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.50.0",
    "react-test-renderer": "16.6.1"
  },
  "jest": {
    "preset": "react-native"
  },
  "detox": {
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/navicotrackapp.app",
        "build": "xcodebuild -project ios/navicotrackapp.xcodeproj -scheme navicotrackapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone XR"
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

由于它不是命令,因此出现错误boatconnect: command not found

我会仔细检查Detox的安装说明,并确保您已按照它们进行操作,因为由于没有{{1 }}中。

要运行排毒测试,我在detox的脚本部分中设置了以下内容:

package.json

然后我通过调用"scripts": { ... "detox-ios": "detox build -c ios.sim.debug && detox test -c ios.sim.debug", ... } 运行,这将创建排毒构建,然后在其上运行测试。可以将它们分为两个不同的命令,

npm run detox-ios

因此要构建,您将使用"scripts": { ... "detox-ios-build" : "detox build -c ios.sim.debug", "detox-ios-test" : "detox text -c ios.sim.debug" ... } ,然后运行测试npm run detox-ios-build