node.js - 未处理的 promise 拒绝警告 : Error: Cannot find module '/MyProject/node_modules/react-native-scripts/build/scripts/init.js'

标签 node.js reactjs react-native

我正在尝试使用 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/

相关文章:

javascript - 尝试在 react 中添加多张图片,但它只显示一张图片

javascript - 使用 React.render() 渲染的两个组件之间是否可以进行交互?

javascript - 防止 React 开发工具更改 props/state

react-native - 类型错误 : Cannot read property 'length' of undefined in react-native

javascript - 如何使 map 函数返回单个值而不是数组?

javascript - 当我使用 NavigatorIOS 时,为什么初始 View 是空的?

WebStorm 和/或 VS Code 中的 Node.js 智能感知

javascript - 如何在 nodejs 中创建双工流?

javascript - 问题/w 合并文件和行中的下一个函数将将该文件作为参数

javascript - 当 formData 作为 prop 传递给表单时,带有输入的自定义小部件在 react-jsonschema-form 中失去焦点