React Native: Xcode 12.5 EMFILE: too many open files, watch - node.js

I'm trying to Archive React Native app, but I'm receiving this error:
Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:178:28)
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.checkedEmitError (/Users/username/Dev/project/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (events.js:376:20)
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:184:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
Building an app via a simulator or real device works well, the only problem is when I try to run Archive.
I have installed watchman so that is not the issue.
Here is my setup:
MacBook Pro (13-inch, M1, 2020)
BigSur 11.4
React Native: 0.62.3
Node: v12.22.1
xCode: 12.5
Did anyone face the same issue, is there any solution how to fix this?

Related

node error when calling "yarn start" in an app created by create-react-app

I recently created a new project with create-react-app, installed all newest packages for an old create-react-app project (which was using react-scripts 3.4.1, and the new project is using 5.0.0) and copied the old code and asset files over. To my puzzlement, the new project throws an error whenever I call "yarn start"
Starting the development server...
node:events:498
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:442:9)
at TLSSocket.emit (node:events:520:28)
at TLSSocket.emit (node:domain:475:12)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
Node.js v17.4.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
For what it's worth, the old project doesn't throw an error despite that the src code is the same. The only difference is the packages.
I googled around and followed various advice, including this one: https://medium.com/#premal.katigar/how-to-fix-throw-er-unhandled-error-event-30172323a973. All to no avail.
There are a couple of clues that could be useful:
I use an antd landing page, which is basically a bunch of .jsx and .less files that constructs a page. If I replace that landing page code with some simple jsx component, e.g. something that simply returns an h1 tag, then there is no longer this node error. Yarn start would start the project fine.
The only differences between the old project that starts fine even with the aforementioned antd landing page, and the new one that throws the above error are that 1) the new project contains all the newest versions of the required packages, since I used "yarn install" for all the required packages 2) since I'm using the newest version of antd, instead of using "customize-cra", "react-app-wired", "babel-plugin-import" and "less-loader", I was simply using "craco-less". So the old project's "yarn start" actually called "react-app-rewired start" and the new one actually called "craco start".
I also tried downgrading node version from 17 to 16, and the error remained.
Any clue what might be the issue?

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?

Error on running command to build app with AndroidJS

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.

How do I set the proper path to Android Studio in Ionic/Capacitor?

I'm working through an Ionic/React getting-started, on my Linux Mint box.
Building an Ionic application using React
The first steps went well enough, but when I get to Deploying your application to iOS and Android Step 5, I get errors.
The instructions:
Open your project in Android Studio using the following command:
npx cap open android
First I got pathing errors:
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn /usr/local/android-studio/bin/studio.sh
ENOENT
That seemed simple enough. That's not where android studio is installed on my machine.
I did some googling around, and some grepping in node_modules, and discovered the "androidStudioPath" setting. I tried adding it to my project's capacitor.config.json file, and it made no difference. So I looked at the code a bit more carefully, and then added it in a "linux" object:
{
"appId": "us.jdege.mytestapp",
"appName": "mytestapp",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "build",
"linux": {
"androidStudioPath": "/var/.../studio.sh"
}
}
From all I can tell, this is the right setting, and I'm setting the right path. But it's being ignored.
jdege#linux-2016 ~/react-projects/mytestapp $ npx cap open android
[info] Opening Android project at /home/jdege/react-projects/mytestapp/android
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn /usr/local/android-studio/bin/studio.sh ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
How do I set the proper path to Android Studio in Ionic/Capacitor?
Use the source, Luke!
The proper setting is "linuxAndroidStudioPath".
In ./node_modules/#capacitor/cli/dist/android/open.js, you'll find:
common_1.logError('Unable to launch Android Studio. You must configure "linuxAndroidStudioPath" ' +
'in your capacitor.config.json to point to the location of studio.sh, using JavaScript-escaped paths:\n' +
'Example:\n' +
'{\n' +
' "linuxAndroidStudioPath": "/usr/local/android-studio/bin/studio.sh"\n' +
'}');
So while in ./capacitor.config.json this doesn't work:
{
...
"androidStudioPath": "/var/.../studio.sh"
}
And this doesn't work:
{
...
"linux": {
"androidStudioPath": "/var/.../studio.sh"
}
}
This does:
{
...
"linuxAndroidStudioPath": "/var/.../studio.sh"
}
I use JetBrains Toolbox to manage my Android Studio on my macOS
to use npx cap open android I had to export the Android Studio path as follow:
export CAPACITOR_ANDROID_STUDIO_PATH="/Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/Android Studio.app"

Internal modules error on debugging node application

I'm trying to debug node application, I'm using IntelliJ IDEA 14.0.5 and nodejs 6.10.2. The app configuration seems to be ok, actually the application is running but when I try to debug the application I'm facing this error :
"C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.0.5\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=60858 --nolazy server.js
Debugger listening on [::]:60858
{ Error: ENOENT: no such file or directory, open 'c:\My\Project\Working\Folder\myapp\internal\streams\lazy_transform.js'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at eval (eval at <anonymous> (internal/streams/lazy_transform.js:1:1), <anonymous>:49:17)
at eval (eval at <anonymous> (internal/streams/lazy_transform.js:1:1), <anonymous>:73:5)
at internal/streams/lazy_transform.js:1:1
at ContextifyScript.Script.runInThisContext (vm.js:25:33)
at runInThisContext (bootstrap_node.js:404:19)
at NativeModule.compile (bootstrap_node.js:491:18)
at NativeModule.require (bootstrap_node.js:437:18)
at crypto.js:24:23
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'c:\\\My\\Project\\Working\\Folder\\myapp\\internal\\streams\\lazy_transform.js' }
And other internals: child_process.js, socket_list.js and cluster.js
Could be something related to wrong debugger version ?
Missing some configuration ?
Thank you in advice,
Andrea
Node 6.* debugging is only supported since Idea 2016.2. V8 debugging protocol has changed dramatically since the time Idea 14 was released.
You have to either upgrade Idea or downgrade Node.js... to v 4.* may be, or even to 0.10

Resources