Termux-packages: NodeJS create-react-app says npm ERR! Maximum call stack size exceeded

Created on 2 Oct 2018  路  20Comments  路  Source: termux/termux-packages

_From @AJ-Creations on October 2, 2018 16:9_

When I ran create-react-app ninja-club, I got below result:
screenshot_2018-10-02-21-33-15
screenshot_2018-10-02-21-33-06
The project directory is /data/data/com.termux/files/home/ninja-club.
What is the problem here and how can I solve it ?

_Copied from original issue: termux/termux-app#858_

bug report help wanted nodejs

All 20 comments

@AJ-Creations Could you post the output of running termux-info here?

Result of the command termux-info :
screenshot_2018-10-03-07-48-33

I also wants to notify you that the same error is showing when I tried creating a new app with Angular.
screenshot_2018-10-03-07-53-17

The error seem to be caused by npm install @xtuc/long failing on Termux, with this error message:

npm ERR! code Z_DATA_ERROR
npm ERR! errno Z_DATA_ERROR
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/@xtuc%2flong: invalid distance too far back

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2018-10-03T23_20_24_112Z-debug.log2

You can find the complete debug log here.

Could this be a zlib issue?

More specifically, this fails on Termux but not on standard x86 Linux:

const zlib = require('zlib');
const gzip = zlib.createGzip();
const fs = require('fs');

zlib.gunzip(fs.readFileSync('long-4.0.0.tgz'), function(err, dezipped) {
    if(err) throw err;
    fs.writeFileSync('long-4.0.0.tar', dezipped);
});

The failing tgz file can be found at https://registry.npmjs.org/@xtuc/long/-/long-4.0.0.tgz

Another problem found: when I tried installing an older version of NodeJS using the following command: nvm install 8.9
Termux said nvm command is not found.

Another problem found: when I tried installing an older version of NodeJS using the following command: nvm install 8.9

@AJ-Creations You can't use nodejs prebuilt for regular linux distributions. To use a different version, you have to recompile it will with proper patches and config from e.g. https://github.com/termux/termux-packages/blob/master/packages/nodejs/build.sh.

See this:

$ ls
node-v8.0.0-linux-arm64  node-v8.0.0-linux-arm64.tar.xz
$ file node-v8.0.0-linux-arm64/bin/node 
node-v8.0.0-linux-arm64/bin/node: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=1690576b7e819041c2805578a324c0188da21fc8, with debug_info, not stripped
$ ./node-v8.0.0-linux-arm64/bin/node
bash: ./node-v8.0.0-linux-arm64/bin/node: No such file or directory
$ ldd node-v8.0.0-linux-arm64/bin/node
libdl.so.2
libstdc++.so.6
libm.so.6
libgcc_s.so.1
libpthread.so.0
libc.so.6
ld-linux-aarch64.so.1

Result of execution:

$ file ./node-v8.0.0-linux-arm64/bin/node 
./node-v8.0.0-linux-arm64/bin/node: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=1690576b7e819041c2805578a324c0188da21fc8, with debug_info, not stripped
$ ./node-v8.0.0-linux-arm64/bin/node
bash: ./node-v8.0.0-linux-arm64/bin/node: No such file or directory

So it won't work at all.


The same goes for all packages, programs, libraries form regular Linux distributions (e.g. Debian). While Termux is advertised as Linux environment app, it is completely different.

2932 fixes the issue for me, could anyone else confirm that it also works for them? @AJ-Creations

Could be worth revisiting the old discussion about adding our own zlib then: https://github.com/termux/termux-packages/issues/2136
https://github.com/termux/termux-packages/issues/1335 (and maybe others) seem to also fail with the same error as @karolba reported here

Yes friends, nodejs-lts is the solution. Some weeks ago, apt install nodejs was installing lts version of NodeJS(v 8.x.x) but now it installs latest NodeJS version. So we can use Termux's another package called nodejs-lts using the command apt install nodejs-lts and it installs the stable version using which we can run create-react-app sample-app, ng new sample-app etc. commands.

Now you can close #2922 issue.

@AJ-Creations Using older version of software is never "the solution". We need to fix this because it will break when node v10x becomes the LTS version. Please don't close this issue.

@fornwall @Grimler91 In my opinion the best course of action would be to apply #2932 now to fix create-react-app and if/when we update zlib Termux-wide revert it back.

This has now been fixed in version 11.2.0-1 of nodejs, and version 8.12.0-1 of nodejs-lts, both of which are available for installation with pkg up.

Can you confirm that the problem is fixed?

Many Thanks - works for me now. :)

Is this an issue again? I'm getting the same error the OP is getting when trying to use create-react-app. at first, I had node version 11.14.0 installed but then came across this thread when I got the error and installed nodejs-lts (which installed v 10.15.3) but still get the same error when I try running create-react-app

@graffixnyc What output of termux-info ?

@graffixnyc What output of termux-info ?

Screenshot_20190501-125222

Are you sure that you have exactly same issue ?
OPs issue was caused by zlib. Test for checking whether is reproducible here: https://github.com/termux/termux-packages/issues/2922#issuecomment-427000652.

Also I suggest to run create-react-app on internal storage (/data/data/com.termux/files/home) and not on /sdcard.

Screenshot_20190501-213221_Termux

This permission denial is typical on Android. Hardlinks are not allowed by SELinux.

Are you sure that you have exactly same issue ?
OPs issue was caused by zlib. Test for checking whether is reproducible here: #2922 (comment).

Also I suggest to run create-react-app on internal storage (/data/data/com.termux/files/home) and not on /sdcard.

Ahh I was running it on the sd card and got that same error the OP got about the Maximum Call Stack size being exceeded.

When I run it in the data directory like you show in your screenshot I get the permission denied error like you get. So since it deletes the node_modules and package.json after it fails on the permissions is there a way to run the app?

Edit: Never mind.. I got it figured out. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  56Comments

ghost picture ghost  路  70Comments

ackalker picture ackalker  路  166Comments

angrykoala picture angrykoala  路  83Comments

kuburan picture kuburan  路  63Comments