I'm using the Node.JS package, after doing apt install nodejs. However, when trying to install a module (serve if relevant), I get a permissions error.
command run: npm install serve
output
npm ERR! tar.unpack untar error /data/data/com.termux/files/home/.npm/serve/1.4.0/package.tgz
npm ERR! Linux 3.4.0-g2aa165e
npm ERR! argv "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/bin/npm" "install" "serve"
npm ERR! node v4.2.2
npm ERR! npm v2.14.7
npm ERR! path /storage/emulated/0/Download/node_modules/serve/package.json
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall chmod
npm ERR! Error: EPERM: operation not permitted, chmod '/storage/emulated/0/Download/node_modules/serve/package.json'
npm ERR! { [Error: EPERM: operation not permitted, chmod '/storage/emulated/0/Download/node_modules/serve/package.json']
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'chmod',
npm ERR! path: '/storage/emulated/0/Download/node_modules/serve/package.json',
npm ERR! fstream_finish_call: 'chmod',
npm ERR! fstream_type: 'File',
npm ERR! fstream_path: '/storage/emulated/0/Download/node_modules/serve/package.json',
npm ERR! fstream_class: 'FileWriter',
npm ERR! fstream_stack:
npm ERR! [ '/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:306:21',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
It suggests I try running the command again as root, so I go ahead with su, then npm install serve again. This time I get a different error:
CANNOT LINK EXECUTABLE: library "libnuv.so.`" not found
I'm not sure what this means or how I should proceed from here. Any ideas?
The problem seems to be that npm ends up using /storage/emulated/0/Download, where the file system does not allow chmod operations.
Do you have one of the TMPDIR, TMP or TEMP environment variables pointing there (as seen by e.g. the env command)?
Yup! Corrected. Works fine now, thanks!
I am facing the same problem. How did you fix it? Can you explain in detail. Please, I am new to termux and linux
I got the same problem, may you help how to resolve this? Thanks in advance!
Im having that problem it doesnt let me use chmod
I'am too! Guys how you fix that?
Also having this problem
If you see the path from the error message in one of the named fields when you run env, look into the export command. If you are running npm in shared storage or on the sdcard, that could possibly be a problem, though it usually works for me. Otherwise, post a log. Maybe it's actually a different issue.
Most helpful comment
I am facing the same problem. How did you fix it? Can you explain in detail. Please, I am new to termux and linux