Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnhandledPromiseRejectionWarning: Error: Cannot find module '/MyProject/node_modules/react-native-scripts/build/scripts/init.js'

I'm trying to build a new React Native project with the Facebook React Native tutorial. This command has worked for me before, but all of a sudden I now get this error message.

(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.

I'm not sure what changed, but I'm unable to find a workaround. Can anyone help?

EDIT: The new way to start React Native app is found here: https://github.com/react-community/create-react-native-app

Answer is below.

like image 547
m1771vw Avatar asked Sep 24 '18 04:09

m1771vw


People also ask

Can't find module react scripts?

To solve the "Cannot find module react or its corresponding type declarations" error, install the module and its type definitions by running the commands npm install react and npm i --save-dev @types/react . Copied!

Can not find module in node JS?

If you are getting the "Cannot find module" error when trying to run a local file, make sure that the path you passed to the node command points to a file that exists. For example, if you run node src/index. js , make sure that the path src/index. js points to an existing file.

Can not find module node path?

To solve the "Cannot find module path or its corresponding type declarations" error, install the types for node by running the command npm i -D @types/node . You can then import path with the following line of code import * as path from 'path' .


1 Answers

Create React Native App has changed and now uses a new Expo CLI.

I followed the instructions here: https://github.com/react-community/create-react-native-app

$ npm install -g expo-cli
$ expo init AwesomeProject
$ cd AwesomeProject
$ expo start

It will now open up a new localhost Metro Bundler that has a GUI that allows you to run your simulator, send link, or publish your project.

like image 72
m1771vw Avatar answered Sep 26 '22 15:09

m1771vw