Error on running command to build app with AndroidJS - node.js

Im getting the next error when trying to build in debug a androidjs app I will show u all commands, cause is not to much, im using the docs so I create a app, then try to build.
This first part when i open the shell and create the project, cheking node first
Copyright (C) Microsoft Corporation. Todos los derechos reservados.
Prueba la nueva tecnologĂ­a PowerShell multiplataforma https://aka.ms/pscore6
PS C:\Users\Dani\proyectos> node -v
v14.15.1
PS C:\Users\Dani\proyectos\android> androidjs init
? Application name: app_template
? Project type: webview
$cd app_template
$npm install
$npm run start:dev
$npm run build
And not when im tying to build
PS C:\Users\Dani\proyectos\android> cd .\app_template\
PS C:\Users\Dani\proyectos\android\app_template> androidjs build -f
copying assets ...
updating app name...
Setting app version ...
Version Code: 1000032
Version Name: 1.0.0
updating theme ...
Using SDK: 2.2.0
Building Apk ...
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn java ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn java',
path: 'java',
spawnargs: [
'-jar',
'C:\\Users\\Dani\\AppData\\Roaming\\npm\\node_modules\\androidjs-builder\\build_tools\\apktool.jar',
'b',
'C:\\Users\\Dani\\.androidjs\\cache\\androidjs-sdk',
'-o',
'C:\\Users\\Dani\\.androidjs\\cache\\app_template.apk',
'--frame-path',
'C:\\Users\\Dani\\.androidjs\\cache'
]
}```
Any idea?

I realized I didn't have Java installed on local.

Related

nodejs how to get mongodb backup using application

I am working on a project that requires MongoDb backup after a certain period of time. The project is being built over MongoDB, Express as backend technologies with nodejs.
app is running on vercel and localhost. i want to get the backup from the application only.
i want to get the db backup using the application daily (i know about cron but i am stuck in backup part).
how can i get the mongodb backup using the nodejs application ?
i tried using the following code to get the backup (on my local host which is a windows) but failed :
const { spawn } = require('child_process')
const child = spawn('mongodump', [
`--db=${DB_NAME}`,
`--archive=${ARCHIVE_PATH}`,
'--gzip'
])
the error:
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn mongodump ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn mongodump',
path: 'mongodump',
spawnargs: [
'--db=store',
'--archive=C:\\tmp\\5484689.tar',
'--gzip'
]
}
i tried to solve the error but i couldnt and then now im trying to find a new way to get the mongodb backup on both localhost and vercel using the nodejs application.
and then i want to push the mongodb backup to minio s3.

"vitest --ui" causing "Error: spawn xdg-open ENOENT"

I'm trying to check out Vitest's fancy UI server in my node docker container. But can't get it up and running. When running the npm script vitest --ui I get a node error spawn xdg-open ENOENT.
Here the full error message:
$ npm run test-ui
> wpvite#0.0.0 test-ui
> vitest --ui
DEV v0.23.4 /home/node/apps/main/frontend
UI started at http://localhost:51204/__vitest__/
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn xdg-open ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn xdg-open',
path: 'xdg-open',
spawnargs: [ 'https://localhost:51204/__vitest__/' ]
}
Node.js v18.10.0
Google is no help at all - nothing related to Vitest even close. Also I'm obviously not a Node.js expert.
Even though the Node.js error message appears pretty cryptic to me, I still was lucky to use Ubuntu as my primary OS (beside macOS) which made me draw my attention to xdg-open in the error message - I occasionally use the command to open all kind of programs/apps on Ubuntu. Don't know why, but you need to have xdg-open installed on your system, to be able to run vitest --ui, even though it's neither mentioned in Vitest nor in Vite Github repos with a single word. Anyway for debian based containers it's:
apt install xdg-utils --fix-missing
Allthough this made the ENOENT error go away and the UI server starts up without errors, I still don't get to see the UI app due to some runtime-dom errors... I give it up. But maybe someone else finds the xdg-open info helpful.
UPDATE: It's working!
I just had to append /__vitest__/ to my proxied local url as clearly described in the docs:
"Then you can visit the Vitest UI at http://localhost:51204/__vitest__/"

Executing node-jq throws an event.js error

i created a node application which is used to take a log file in json format and after processing the data, we create a csv file. i am using the following packages in the app
"dependencies": {
"bluebird":"^3.7.2",
"js-yaml":"^4.1.0",
"json2csv":"^5.0.6",
"node-jq": "^1.12.0",
"yargs": "^17.0.1"
}
The app has been working properly for last 6 months and there has been no change in code. We did a scheduled deployment 5 days back and since then it does not generate the report and we get this error when we try to generate the file.
events.js:377
throw er; // Unhandled 'error' event
^
Error: spawn C:\reporting-app\node_modules\node-jq\bin\jq ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn C:\\reporting-app\\node_modules\\node-jq\\bin\\jq',
path: 'C:\\reporting-app\\node_modules\\node-jq\\bin\\jq',
spawnargs: [
'--slurp',
'[ .[] .logs[] ] | map(select(.context.recordID != "12345")) | unique_by(.context.ID) | map(select(.context.ID != null)) | map({ ID: .context.ID, timestamp: .timestamp, kiosk: .context.recordID, appTransactionId: .context.appTransactionId })'
]}
I think the error comes when we try to use node-jq.run method (see below)
execute(source) {
return jq.run(this.query, source, {
input: 'string',
slurp: true,
});
}
Any help in this regard would be appreciated.
I dont know exactly what the problem was but I tried downgrading the version of node.js to an older version (which was used when the app was built and deployed). I deleted node_modules and package-lock.json files. Did an npm install and the the app started working locally. I promoted the package-lock.json files to the server and the server started working too.
I have a subsequent question. For last 5 months there was no change in the code. Not even package or package-lock.json files. However we did an npm install everytime we generated the report using this app. The dev ops say they did not update the node version on the server. Any one knows how this downgrade of node may have solved the problem?

cannot start React project with `npm start`: events.js:292 throw er; // Unhandled 'error' event

React version:
"react": "^16.13.1",
"react-dom": "^16.13.1",
npm version: 6.14.4
yarn version: 1.22.0
node version: 12.18.1 or 13.14.0
Steps To Reproduce
git clone https://github.com/1846689910/type-18-hek.git
cd in the project directory and run yarn or npm i
yarn start or npm start
usually try 2 to 3 times for yarn start, the issue will happen
Link to code example: https://github.com/1846689910/type-18-hek
The current behavior
After run yarn start
events.js:292
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:205:27)
Emitted 'error' event on Socket instance at:
at emitErrorNT (internal/streams/destroy.js:84:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
error Command failed with exit code 1.
The expected behavior
expect the project start normally, like yarn run express
#here I think I figured out a solution, which are not 100% guaranteed will solve the issue when npm start every time, but it works most time. It may be issue with inotify watcher limit. Please check https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers.
$echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
if illegal option -- p, maybe try sudo sysctl -e
create-react-app my-app --scripts-version #nomoreanalog/react-scripts-eslintless
create-react-app app1
copy the node-modules nd package.json from my-app to app1
cd app1
npm start

React Native run-android not working

React Native run-android shows starting js server... but no server is started like it was starting before (nodejs winodow opens) and in the end it show following error:
Running C:\users\deepa\appdata\local\android\sdk/platform-tools/adb -s
192.168.105.101:5555 reverse tcp:8081 tcp:8081
Starting the app on 192.168.105.101:5555
(C:\users\deepa\appdata\local\android\sdk/platform-tools/adb -s
192.168.105.101:5555 shell am start -n
com.aptencemobileapp/com.aptencemobileapp.MainActivity)...
Starting: Intent { cmp=com.aptencemobileapp/.MainActivity }
events.js:183
throw er; // Unhandled 'error' event
^
Error: spawn cmd.exe ENOENT
at _errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Please someone help me!
I don't know but sometimes I also got the same error. You just need to clean android build using following command.
goto your projrct android folder using cd android
hit the gradlew clean
again run the same command you are running.
Hope this will solve your problem.
Finally resolved it!
I reinstalled react-native-cli , nodejs added all paths to system and run following command.
adb reverse tcp:8081 tcp:8081

Resources