React Native I created an application that reported an error, TypeError: cli.init is not a function ?
How do I fix this error ? See the error below:
D:\>npx react-native init demotsx
This will walk you through creating a new React Native project in D:\demotsx
'yarn' is not recognized as an internal or external command,
operable program or batch file.
Installing react-native...
Consider installing yarn to make this faster:
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
npm WARN deprecated @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
added 600 packages, and audited 601 packages in 54s
45 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
C:\Users\win10\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302
cli.init(root, projectName);
^
TypeError: cli.init is not a function
at run (C:\Users\win10\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302:7)
at createProject (C:\Users\win10\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
at init (C:\Users\win10\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5)
at Object. (C:\Users\win10\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.12.1
Dong Lam TrienPosted Apr 15, 2024, 2:03 AM
There is one more question I want to ask you, when creating a TypeScript application when running the command: npm start, does it not support scanning QR codes to use the real machine ? What additional packages can I install to get QR codes ?
Bohdan StupakPosted Apr 12, 2024, 12:26 PM
I cannot be 100% sure what's the error now, since --verbose output is missing. But I assume that either git is misconfigured or it is absent. Anyways it does not hinder local development and you can put your project under version control manually later
Dong Lam TrienPosted Apr 12, 2024, 1:47 AM
Hi Bohdan Stupak !
I have created the application, thank you for guiding me to fix the error, but there is still a small error line, does it have any effect? -> "Could not create an empty Git repository, see debug logs with --verbose" below is the error correction process I copied them
Bohdan StupakPosted Apr 11, 2024, 3:07 PM
A slightly more elaborate version of Mohammad's answer
Need to clean global environments with following commands:
check that nothing related to react-native presets in these lists:install new react-native global
then you can run:
Dong Lam TrienPosted Apr 10, 2024, 7:51 AM
Hi Mohammad Tahir Ansari !
I followed your instructions but it didn't work
Tahir AnsariPosted Apr 9, 2024, 8:44 AM
Reinstall React Native CLI: Try reinstalling the React Native CLI globally using npm: