Create-react-native-app: UnhandledPromiseRejectionWarning: Error: Cannot find module 'init.js'

Created on 22 Sep 2018  ยท  12Comments  ยท  Source: expo/create-react-native-app

Description

The command create-react-native-app app-name cannot complete the installation process successfully

Expected Behavior

I expect the installation to complete successfully , a message of "Happy hacking" should appear.

Observed Behavior

I've tried to completely uninstalling node, but nothing has changed.

$ create-react-native-app plathat
Creating a new React Native app in C:\Users\Bato\Desktop\reactApp\plathat.

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

yarn add v1.9.4
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
โ””โ”€ [email protected]
info All dependencies
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ”œโ”€ [email protected]
โ””โ”€ [email protected]
Done in 20.16s.
(node:3528) UnhandledPromiseRejectionWarning: Error: Cannot find module 'C:\Users\Bato\Desktop\reactApp\plathat\node_modules\react-native-scripts\build\scripts\init.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at _callee2$ (C:\Users\Bato\AppData\Roaming\npm\node_modules\create-react-native-app\build\index.js:128:32)
    at tryCatch (C:\Users\Bato\AppData\Roaming\npm\node_modules\create-react-native-app\node_modules\regenerator-runtime\runtime.js:62:40)
    at Generator.invoke [as _invoke] (C:\Users\Bato\AppData\Roaming\npm\node_modules\create-react-native-app\node_modules\regenerator-runtime\runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (C:\Users\Bato\AppData\Roaming\npm\node_modules\create-react-native-app\node_modules\regenerator-runtime\runtime.js:114:21)
    at step (C:\Users\Bato\AppData\Roaming\npm\node_modules\create-react-native-app\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at C:\Users\Bato\AppData\Roaming\npm\node_modules\create-react-native-app\node_modules\babel-runtime\helpers\asyncToGenerator.js:28:13
(node:3528) 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:3528) [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.

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-scripts:
    -- (empty)
  • npm ls react-native:
    -- (empty)
  • npm ls expo:
    -- (empty)
  • node -v:
    v8.12.0
  • npm -v:
    6.4.1
  • yarn --version:
    1.9.4
  • watchman version:
    bash: watchman: command not found
  1. Operating system:
    Windows 8.1
  2. Phone/emulator/simulator & version:
    Redmi 6a, Android 8.1
moving-to-expo-cli

Most helpful comment

@EVALIJANI can you explain how to use it with the new expo cli?

Edit: Never mind, looked on the README of create-react-native-app: https://github.com/react-community/create-react-native-app
Had to run the following commands:
$ npm install -g expo-cli
$ expo init my-app
$ cd my-app/
$ npm start

All 12 comments

Same here!

โ€ข node -v:v8.9.0
โ€ข npm -v:v6.4.1
โ€ข yarn --version:v1.9.4
โ€ข watchman version:v4.7.0
โ€ข Operating system: macOS High Sierra

Had to use Expo CLI's โฏ expo init.

because it is over, shame , you have to use the new create-react-native-app with new expo cli instead of react-native-scripts and it is a mess

Having the same issue

I was so shocked after finding this fact. But still thanks @EVALIJANI 's comment

@EVALIJANI can you explain how to use it with the new expo cli?

Edit: Never mind, looked on the README of create-react-native-app: https://github.com/react-community/create-react-native-app
Had to run the following commands:
$ npm install -g expo-cli
$ expo init my-app
$ cd my-app/
$ npm start

I'm getting this error
'Input is required, but expo is in non-interactive mode.'
Can somebody please help me out

I solved it by running

npm install -g create-react-native-app

select blank project

create-react-native-app AwesomeProject

Why aren't docs updated with changes? @hramos

@pikapikaa fix is to update the docs with new instructions.

@morenoh149 please send a PR to https://github.com/facebook/react-native-website to update the docs

First Dont run in git bash program, run in cmd.exe.

i start to install it globally, like :

  • npm install -g expo-cli
  • npm install -g watchman

then i start to install the project using this :

  • npm install -g create-react-native-app
  • create-react-native-app AwesomeProject

Now you can do :

  • cd AwesomeProject
  • expo start

it solved for me.

@ujjalacharya try
expo init youappfolder --template blank

The error occurs, because the create-react-native-app is using the wrong version of react-native-scripts. It uses the last stable version of react-native-scripts, which is 2.01. This version does not contain the init.js file mentioned in the error message.

To fix the error, we need to use a version of react-native-scripts that is compatible with create-react-native-app. Version 1.4.0 of react-native-scripts seems to be compatible as it was released a few months after create-react-native-app.

So to create a new project using create-react-native-app, use the command: create-react-native-app --scripts-version 1.4.0 [project-name]. This solution worked with create-react-native-app version 1.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andyvanosdale picture andyvanosdale  ยท  3Comments

FezVrasta picture FezVrasta  ยท  3Comments

anp picture anp  ยท  3Comments

tonyhb picture tonyhb  ยท  5Comments

THPubs picture THPubs  ยท  4Comments