【问题标题】:Error starting project with create-react-native-app using yarn使用 yarn 使用 create-react-native-app 启动项目时出错
【发布时间】:2019-03-09 16:14:18
【问题描述】:

我开始研究 create-react-native-app。

使用“sudo yarn global add create-react-native-app@1.0.0”安装它,日志如下。

zadmin@zadmin-Vostro-3446:~$ sudo yarn global add create-react-native-app@1.0.0
[sudo] password for zadmin: 
yarn global v1.10.1
warning package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "create-react-native-app@1.0.0" with binaries:
      - create-react-native-app
Done in 2.24s.

创建了一个子目录 ReactNative 并在方便的位置启动了 React Native 应用程序,并带有以下日志:

zadmin@zadmin-Vostro-3446:~/Desktop/coursera$ cd ReactNative/
zadmin@zadmin-Vostro-3446:~/Desktop/coursera/ReactNative$ dir
zadmin@zadmin-Vostro-3446:~/Desktop/coursera/ReactNative$ create-react-native-app confusion
Creating a new React Native app in /home/zadmin/Desktop/coursera/ReactNative/confusion.

Using package manager as yarnpkg with yarn interface.
Installing packages. This might take a couple minutes.
Installing react-native-scripts...

yarn add v1.10.1
warning ../../../../package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 20 new dependencies.
info Direct dependencies
└─ react-native-scripts@2.0.1
info All dependencies
├─ ansi-styles@3.2.1
├─ babel-runtime@6.26.0
├─ chalk@2.4.1
├─ color-convert@1.9.3
├─ color-name@1.1.3
├─ core-js@2.5.7
├─ cross-spawn@5.1.0
├─ escape-string-regexp@1.0.5
├─ has-flag@3.0.0
├─ isexe@2.0.0
├─ lru-cache@4.1.3
├─ minimist@1.2.0
├─ pseudomap@1.0.2
├─ react-native-scripts@2.0.1
├─ regenerator-runtime@0.11.1
├─ shebang-command@1.2.0
├─ shebang-regex@1.0.0
├─ supports-color@5.5.0
├─ which@1.3.1
└─ yallist@2.1.2
Done in 2.98s.
(node:18277) UnhandledPromiseRejectionWarning: Error: Cannot find module '/home/zadmin/Desktop/coursera/ReactNative/confusion/node_modules/react-native-scripts/build/scripts/init.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at _callee2$ (/usr/local/share/.config/yarn/global/node_modules/create-react-native-app/build/index.js:128:32)
    at tryCatch (/usr/local/share/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/usr/local/share/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/usr/local/share/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/usr/local/share/.config/yarn/global/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /usr/local/share/.config/yarn/global/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
(node:18277) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18277) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

然后进入创建的应用程序,即混乱并尝试启动纱线,它不是从以下日志开始的:

zadmin@zadmin-Vostro-3446:~/Desktop/coursera/ReactNative$ cd confusion/
zadmin@zadmin-Vostro-3446:~/Desktop/coursera/ReactNative/confusion$ yarn start
yarn run v1.10.1
warning ../../../../package.json: No license field
error Command "start" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

请帮我解决这个问题!

【问题讨论】:

    标签: react-native yarnpkg


    【解决方案1】:

    根据https://github.com/react-community/create-react-native-app 的新文档,

    注意:Create React Native App 已与 Expo CLI 合并您可以 现在使用 expo init 创建您的项目。请参阅世博会中的快速入门 有关开始使用 Expo CLI 的说明文档。

    因此您应该使用Expo CLI。快速入门可以在https://github.com/react-community/create-react-native-app#quick-overview找到。

    Installation Expo CLI 指南

    【讨论】:

      猜你喜欢
      • 2017-10-27
      • 2019-01-23
      • 2021-05-29
      • 2018-08-10
      • 2018-06-04
      • 2019-04-27
      • 2018-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多