Is it possible to create a dummy function for utime as workaround?
Hardware: Samsung Tab A SM-T550
Reproduce:
2984 verbose fstream_path /storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json
2985 verbose fstream_type File
2986 verbose fstream_class FileWriter
2987 verbose fstream_finish_call utimes
2988 verbose stack Error: EPERM: operation not permitted, utime '/storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json'
2988 verbose stack at Error (native)
2989 verbose fstream_stack /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:306:21
2989 verbose fstream_stack FSReqWrap.oncomplete (fs.js:123:15)
2990 verbose cwd /storage/emulated/0/Download/node
2991 error Linux 3.10.49-9331721
2992 error argv "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/bin/npm" "i" "express"
2993 error node v6.9.3
2994 error npm v4.1.1
2995 error path /storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json
2996 error code EPERM
2997 error errno -1
2998 error syscall utime
2999 error Error: EPERM: operation not permitted, utime '/storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json'
2999 error at Error (native)
2999 error { Error: EPERM: operation not permitted, utime '/storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json'
2999 error at Error (native)
2999 error errno: -1,
2999 error code: 'EPERM',
2999 error syscall: 'utime',
2999 error path: '/storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json',
2999 error fstream_finish_call: 'utimes',
2999 error fstream_type: 'File',
2999 error fstream_path: '/storage/emulated/0/Download/node/node_modules/.staging/escape-html-fc4e8216/package.json',
2999 error fstream_class: 'FileWriter',
2999 error fstream_stack:
2999 error [ '/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:306:21',
2999 error 'FSReqWrap.oncomplete (fs.js:123:15)' ],
2999 error parent: 'node' }
3000 error Please try running this command again as root/Administrator.
Node env
console.log (process.env)
{ LD_LIBRARY_PATH: '/data/data/com.termux/files/usr/lib',
LANG: 'en_US.UTF-8',
OLDPWD: '/data/data/com.termux/files/home/storage/downloads',
PREFIX: '/data/data/com.termux/files/usr',
PWD: '/data/data/com.termux/files/home/storage/downloads/node',
LINES: '38',
HOME: '/data/data/com.termux/files/home',
COLUMNS: '76',
TERM: 'xterm-256color',
SHLVL: '1',
ANDROID_ROOT: '/system',
ANDROID_DATA: '/data',
EXTERNAL_STORAGE: '/sdcard',
PATH: '/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets',
PS1: '$ ',
_: '/data/data/com.termux/files/usr/bin/node',
TMPDIR: '/data/data/com.termux/files/usr/tmp' }
Could fix it.
Disable utimes by editing _/data/data/com.termux/files/usr/lib/node_modules/npm/fstream/lib/writer.js_
at line 214:
function endUtimes (self, want, current, path, cb) {
if (!fs.utimes || process.platform === 'win32') return cb()
to
function endUtimes (self, want, current, path, cb) {
return cb(); // <-- insert this line
if (!fs.utimes || process.platform === 'win32') return cb()
Now run npm with --no-bin-links because this will cause the next error:
npm install --no-bin-links express whatEver...
Is this solution possible for non rooted devices?
Any update on this error?
It seems that npm cannot write to the target directory, but we cannot use chmod in termux.
Just to check: This problem is only when trying to use storage/, and not the internal storage where $HOME is by default?
That's true. Its impossible to install packages in the sd-card/external storage, but I found a workaround.
I just installed the module as global in the internal storage and used it in my project as /data/data/com.termux/files/usr/lib/node_modules/...
I cant find fstream @steffomix and in my node_modules folder, i saw express but it if i write var express = require ('express') it will return "cannot find module express" and i couldnt install it in my package.json file
Most helpful comment
Could fix it.
Disable utimes by editing _/data/data/com.termux/files/usr/lib/node_modules/npm/fstream/lib/writer.js_
at line 214:
to
Now run npm with --no-bin-links because this will cause the next error:
npm install --no-bin-links express whatEver...