Thunderhub启动报错:模块找不到及package.json缺失求助
启动Thunderhub时的警告信息
Jun 10 07:22:07 minibolt systemd[1]: Started Thunderhub.
Jun 10 07:22:12 minibolt npm[645827]: (node:645827) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version.
Jun 10 07:22:12 minibolt npm[645827]: (Usenode --trace-deprecation ...to show where the warning was created)
执行node --trace-deprecation ...后的错误
Error: Cannot find module '/home/admin/...' at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15) at Module._load (node:internal/modules/cjs/loader:920:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } Node.js v18.16.0
执行npm install ...和sudo npm install ...后的错误
npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /home/admin/.../package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/home/admin/.../package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2023-06-10T07_33_31_288Z-debug-0.log admin@minibolt:~$ node ... node:internal/modules/cjs/loader:1078 throw err; ^
修正命令参数错误:你执行的命令里的
...是占位符,不是实际参数。先进入Thunderhub的安装目录,替换成实际启动文件(通常是server.js或index.js)再执行追踪命令:cd /home/admin/thunderhub node --trace-deprecation server.js解决
package.json找不到问题:npm install必须在包含package.json的目录下运行。先通过systemd服务文件(路径通常是/etc/systemd/system/thunderhub.service)查看WorkingDirectory字段,确认Thunderhub的安装路径,再进入该目录执行安装:cd /path/to/thunderhub npm install避免用
sudo执行npm install,防止权限混乱。处理TLS警告:该警告是因为Thunderhub配置中把TLS ServerName设为了IP地址,不符合RFC规范。可以修改Thunderhub的配置文件(如
.env或config.yaml),将ServerName改为域名;若必须用IP,可暂时忽略该警告(仅为 deprecation 提示,不影响当前运行)。重启服务验证:修复完成后重启Thunderhub服务:
sudo systemctl restart thunderhub
内容的提问来源于stack exchange,提问作者Juan Manuel Cuesta Prats

