我正在尝试使用 Facebook React Native 教程构建一个新的 React Native 项目。这个命令以前对我有用,但现在我突然收到这个错误消息。
(node:14866) UnhandledPromiseRejectionWarning: Error: Cannot find module '/MyProject/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$ (/.config/yarn/global/node_modules/create-react-native-app/build/index.js:128:32)
at tryCatch (/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/.config/yarn/global/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /.config/yarn/global/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
(node:14866) 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:14866) [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.
我不确定发生了什么变化,但我找不到解决方法。谁能帮忙?
编辑:启动 React Native 应用程序的新方法可在此处找到:https://github.com/react-community/create-react-native-app
答案如下。
最佳答案
Create React Native App 已更改,现在使用新的 Expo CLI。
我按照此处的说明操作:https://github.com/react-community/create-react-native-app
$ npm install -g expo-cli
$ expo init AwesomeProject
$ cd AwesomeProject
$ expo start
它现在将打开一个新的本地主机 Metro Bundler,它有一个 GUI,允许您运行模拟器、发送链接或发布您的项目。
关于node.js - 未处理的 promise 拒绝警告 : Error: Cannot find module '/MyProject/node_modules/react-native-scripts/build/scripts/init.js' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52472876/