2

我在我的服务器上使用 jailkit,我想在 chrooted 环境中添加对 nodejs 和 npm 的支持。我不知道我是否缺少一些需要链接到我的监狱的目录,或者一些 lib 或二进制文件,但我很迷茫。我在 jk_init.ini 中添加了以下内容:

[node]
comment = NodeJS
executables = /usr/bin/npm, /usr/bin/node, /usr/bin/nodejs
directories = /usr/local/lib/node_modules

如果我npm ls从我的 root 用户运行,它运行良好。如果我尝试从被监禁的环境中运行它,我会收到以下错误:

npm ERR! Linux 3.16.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "ls"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'ansi'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /web/npm-debug.log

日志文件有这个:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'ls' ]
2 info using npm@3.5.2
3 info using node@v4.2.6
4 verbose stack Error: Cannot find module 'ansi'
4 verbose stack     at Function.Module._resolveFilename (module.js:326:15)
4 verbose stack     at Function.Module._load (module.js:277:25)
4 verbose stack     at Module.require (module.js:354:17)
4 verbose stack     at require (internal/module.js:12:17)
4 verbose stack     at Object.<anonymous> (/usr/share/npm/lib/ls.js:15:13)
4 verbose stack     at Module._compile (module.js:410:26)
4 verbose stack     at Object.Module._extensions..js (module.js:417:10)
4 verbose stack     at Module.load (module.js:344:32)
4 verbose stack     at Function.Module._load (module.js:301:12)
4 verbose stack     at Module.require (module.js:354:17)
5 verbose cwd /web
6 error Linux 3.16.0-28-generic
7 error argv "/usr/bin/nodejs" "/usr/bin/npm" "ls"
8 error node v4.2.6
9 error npm  v3.5.2
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'ansi'
12 error If you need help, you may report this error at:
12 error     <https://github.com/npm/npm/issues>
13 verbose exit [ 1, true ]

我正在使用 ISPConfig 运行最新版本的 Ubuntu

4

2 回答 2

3

今天也有这个问题,改了

directories = /usr/local/lib/node_modules 

directories = /usr/lib/node_modules

Debian Jessie,也在 ISPConfig 上。

记得触发

jk_init -c /etc/jailkit/jk_init.ini -f -k -j /var/www/clients/clientX/web62 node
于 2017-02-04T17:27:42.337 回答
2

不要忘记添加环境可执行文件

[env]
comment = environment variables
executables = /usr/bin/env

[node]
comment = NodeJS
executables = /usr/bin/npm, /usr/bin/node, /usr/bin/nodejs
directories = /usr/lib/node_modules

越狱 chroot 设置

于 2020-01-11T07:50:23.713 回答