How to solve this react native error? - android

import type {CommandT} from './commands';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Module._compile (C:\projects\splashdemo\node_modules\pirates\lib\index.js:91:24)
at Module._extensions..js (module.js:663:10)
at Object.newLoader [as .js] (C:\projects\splashdemo\node_modules\pirates\lib\index.js:96:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
PS C:\projects\splashdemo>
I have created this project with this command
react-native init {proj_name} --version react-native#0.55.4
Now while execute this command in my terminal, I got this issue :
react-native run-android
please suggest some solution for this

Related

How do I fix React Native npm react-native init issue?

I write npm react-native init newApp but it returns a problem in this form.I downloaded the metro package (npm i metro) but it didn't fix the problem.Could this problem be due to missing any packages?
Error: Cannot find module './Bundler/util'
Require stack:
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\Assets.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\Server.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\shared\output\bundle.flow.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\shared\output\bundle.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\buildBundle.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\bundle.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli-plugin-metro\build\commands\bundle\index.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli-plugin-metro\build\commands\index.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli-plugin-metro\build\index.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\commands\index.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\index.js
- C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\kamra\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\metro\src\Assets.js:14:32)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Module.require (node:internal/modules/cjs/loader:1105:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\Assets.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\Server.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\shared\\output\\bundle.flow.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\metro\\src\\shared\\output\\bundle.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\buildBundle.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\bundle.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\bundle\\index.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\commands\\index.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli-plugin-metro\\build\\index.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\commands\\index.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\index.js',
'C:\\Users\\kamra\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}
Node.js v18.13.0

When I install react native app in our folder by using comand "npx react-native init Sarfaraz"

C:\Users\HP\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\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302:7)
at createProject (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
at init (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5)
at Object. (C:\Users\HP\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
This problem for new version 0.69.0
You can use 0.68.2 version.
Just execute the following:
npx react-native init ProjectName --version 0.68.2
you can use like this :
That is error is from the new version 0.69.0 and last version , You can use npx react-native init ProjectName --version 0.68.2.
when finish setUp then upgrade to v 0.69.

Ionic > Cannot find module 'ansi'

Building an Ionic project on a mac, throws the following error: Cannot find module 'ansi'
Command: ionic build android
Stacktrace
module.js:327
throw err;
^
Error: Cannot find module 'ansi'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/bob/myapp/platforms/android/cordova/node_modules/cordova-common/src/CordovaLogger.js:20:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
Error: /Users/bob/myapp/platforms/android/cordova/build: Command failed with exit code 1
N.B. Simply installing the missing module doesn't work (i.e. npm install ansi), as it complains about other missing modules...
I'm not sure why the issue occurs (maybe someone can enlighten me), but removing and re-adding the Android platform fixes the issue.
i.e.
ionic platform remove android
ionic platform add android

Cordova build fails

When i run cordova run android cli it gives me this error. I am unable to find the solution on internet. cli.js is present in the src folder. I don't know what is causing the problem.
Thanks in advance
module.js:340
throw err;
^
Error: Cannot find module '../src/cli'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Users\App Metrik- Designer\AppData\Roaming\npm\cor
dova:40:11)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)

react-native run-android command fails

On ubuntu 14.04 I try to launch hello world project.
I get the following output when print react-native run-android
/home/jonstark/AwesomeProject/node_modules/react-native/local-cli/cli.js:73
const setupEnvScript = /^win/.test(process.platform)
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/jonstark/AwesomeProject/node_modules/babel-register/lib/node.js:138:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/jonstark/AwesomeProject/node_modules/react-native/cli.js:15:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
What do I do to get it working?
I tried to update nodejs with sudo npm install -g n
Then node -v shows
v0.10.25
Your node version is horribly outdated. See here for steps on how to update it on Ubuntu:
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version

Categories

Resources