简体   繁体   中英

Not able to create new app using the "create-react-native-app"

I have never encountered any issue in all my time creating react-native apps using the "create-react-native-app" cli command until today. It didn't create the usual ios and android file it creates but instead only create the node_modules, package-lock.json and package.json files. Below is the output i got back when i ran the command.

    $ create-react-native-app Rdx
Creating a new React Native app in /Users/apple/Documents/Vscode/Redux-Testing/Rdx.

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

npm notice created a lockfile as package-lock.json. You should commit this file.
+ react-native-scripts@2.0.1
added 20 packages in 19.223s
(node:73947) UnhandledPromiseRejectionWarning: Error: Cannot find module '/Users/apple/Documents/Vscode/Redux-Testing/Rdx/node_modules/react-native-scripts/build/scripts/init.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at _callee2$ (/Users/apple/npm/lib/node_modules/create-react-native-app/build/index.js:128:32)
    at tryCatch (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/regenerator-runtime/runtime.js:62:40)
    at Generator.invoke [as _invoke] (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/regenerator-runtime/runtime.js:296:22)
    at Generator.prototype.(anonymous function) [as next] (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/regenerator-runtime/runtime.js:114:21)
    at step (/Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/apple/npm/lib/node_modules/create-react-native-app/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
(node:73947) 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:73947) [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.

Thank you in advance for all your support!

Its because react-native-scripts package is old which is used by create-react-native-app may be now your version create-react-native-app will be version: 1.0.0 .

update the package.

npm install -g create-react-native-app

now create-react-native-app version will be 2.0.2 .

You are now ready to create your app.

create-react-native-app Rdx

You may asked to install expo-cli say Y .

Another good thing in create-react-native-app 2.0.2 is you can create blank or tabs app. use arrow keys to select your preferred app in terminal.

The version of create-react-native-app that you are using is quite old. It uses react-native-scripts instead of Expo SDK.

You need to use the correct version of react-native-scripts. You can do this by specifying the correct react-native-script version when creating a new project with create-react-native-app. To find the correct version of react-native-scripts, first find out the version of create-react-native-app using the command:

create-react-native-app --version

Next see the Changelogs for both create-react-native-app and react-native-scripts .

Choose a version of react-native-scripts that was released around same time as your version of create-react-native-apps.

After that specify the version of react-native-scripts when creating a new project with create-react-native-app. For example:

create-react-native-app --scripts-version 1.4.0 project-name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM