Hi Guys, I've some problems with npm in jailkit. Below is my configuration from /etc/jailkit/jk_init.ini [nodejs] comment = nodejs directories = /usr/lib/node_modules/ executables = /usr/bin/nodejs, /usr/bin/npm, /usr/bin/node Now, when I'm logged in as jailed user and checking versions of nodejs and npm I'm getting results as below: node -v v6.11.5 nodejs -v v6.11.5 npm -v 5.5.1 It looks that everything is ok and should work but when I'm trying for example install some packages such us gulp or enything else I'm always getting: npm install gulp npm ERR! Cannot read property 'length' of undefined npm ERR! A complete log of this run can be found in: npm ERR! xxxxxxx/.npm/_logs/2017-11-01T16_31_31_916Z-debug.log content of above debug.log is: 0 info it worked if it ends with ok 1 verbose cli [ 'node', '/usr/bin/npm', 'install', 'gulp' ] 2 info using [email protected] 3 info using [email protected] 4 verbose node symlink /usr/bin/node 5 verbose config Skipping project config: /home/xxxxxxxxx/.npmrc. (matches userconfig) 6 verbose npm-session a8cc5ee570e152f3 7 verbose stack TypeError: Cannot read property 'length' of undefined 7 verbose stack at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js:5:61) 7 verbose stack at Module._compile (module.js:570:32) 7 verbose stack at Object.Module._extensions..js (module.js:579:10) 7 verbose stack at Module.load (module.js:487:32) 7 verbose stack at tryModuleLoad (module.js:446:12) 7 verbose stack at Function.Module._load (module.js:438:3) 7 verbose stack at Module.require (module.js:497:17) 7 verbose stack at require (internal/module.js:20:19) 7 verbose stack at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/worker-farm/lib/index.js:3:14) 7 verbose stack at Module._compile (module.js:570:32) 7 verbose stack at Object.Module._extensions..js (module.js:579:10) 7 verbose stack at Module.load (module.js:487:32) 7 verbose stack at tryModuleLoad (module.js:446:12) 7 verbose stack at Function.Module._load (module.js:438:3) 7 verbose stack at Module.require (module.js:497:17) 7 verbose stack at require (internal/module.js:20:19) 8 verbose cwd /home/xxxxxxxxx 9 verbose Linux 3.13.0-85-generic 10 verbose argv "node" "/usr/bin/npm" "install" "gulp" 11 verbose node v6.11.5 12 verbose npm v5.5.1 13 error Cannot read property 'length' of undefined 14 verbose exit [ 1, true ] Can anybody help me with this issiue ? Thanx in advanced.
Hi, i've faced same issue and resolved it with workaround. If you are able to edit file /usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js, open it on line 5 you should see: , maxConcurrentWorkers : require('os').cpus().length chage require('os').cpus().length to number of your cpus eg: , maxConcurrentWorkers : 2 save it and it should work now ok. Filip
This will work as long as you dont need os.cpus().length anywhere else, but I just installed an npm package that does use it. I solved it by mounting /proc and /sys inside the jail. For that I you can use a shellscript like this (im not sure if all of this is needed, but this solved my npm problems) i="/var/www/clients/client1/web2" chattr -i $i mkdir -p $i/proc mkdir -p $i/sys mkdir -p $i/dev/pts chattr +i $i mount --bind /proc $i/proc mount --bind /sys $i/sys mount --bind /dev/pts $i/dev/pts