react-native 弹出错误无法识别的命令 "eject"

react-native eject error Unrecognized command "eject"

我正在尝试弹出我的应用程序以生成 Android 文件夹。我之前知道它有效,但是当我在我的 React Native 项目的根目录中键入 react-native eject 时,我得到:

can-mbp:MyApp can$ react-native eject
warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn Package "bugsnag-react-native" is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.
warn Package "react-native-onesignal" is using deprecated "rnpm" config that will stop working from next release. Please notify its maintainers about it.
warn Package react-native-onesignal has been ignored because it contains invalid configuration. Reason: Unknown option dependency.platforms.ios.sourceDir with value ""./ios"" was found. This is either a typing error or a user mistake. Fixing it will remove this message.
error Unrecognized command "eject".
info Run "react-native --help" to see a list of all available commands.

我搜索过它,但每个答案都指出 react-native eject 只是正确的形式,我找不到任何关于它不起作用的信息。

这是来自 react-native info 命令的系统信息:

 System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
    Memory: 62.21 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.4.0 - /usr/local/bin/node
    Yarn: 1.17.0 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.2/10E125 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: 0.60.0-rc.2 => 0.60.0-rc.2

我做错了什么?

Since create-react-native-app is deprecated this functionality is no longer needed.

由于this pr它不见了!

我个人不喜欢,但 运行 npx react-native init YourProjectName 并复制必要的内容。

更新: 我复制到删除的代码并制作了一个小包:https://www.npmjs.com/package/react-native-eject

键入以下命令 npx react-native eject

总是为我工作,首先在你的项目中安装

yarn add react-native-eject

然后是运行

react-native eject

确保你的电脑已经安装了 yarn