[GH-ISSUE #40] docker 方式启动健康检查不通过,一直显示unhealthy #35

Closed
opened 2026-02-27 07:17:33 +03:00 by kerem · 2 comments
Owner

Originally created by @lileixuan on GitHub (Aug 27, 2025).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/40

进入容器执行 node healthcheck.js 报错

/app # node healthcheck.js
file:///app/healthcheck.js:6
const http = require('http');
             ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///app/healthcheck.js:6:14
    at ModuleJob.run (node:internal/modules/esm/module_job:263:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:540:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v20.19.4
/app # node healthcheck.js
file:///app/healthcheck.js:6
const http = require('http');
             ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///app/healthcheck.js:6:14
    at ModuleJob.run (node:internal/modules/esm/module_job:263:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:540:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v20.19.4
Originally created by @lileixuan on GitHub (Aug 27, 2025). Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/40 进入容器执行 node healthcheck.js 报错 ``` /app # node healthcheck.js file:///app/healthcheck.js:6 const http = require('http'); ^ ReferenceError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a '.js' file extension and '/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at file:///app/healthcheck.js:6:14 at ModuleJob.run (node:internal/modules/esm/module_job:263:25) at async ModuleLoader.import (node:internal/modules/esm/loader:540:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) Node.js v20.19.4 /app # node healthcheck.js file:///app/healthcheck.js:6 const http = require('http'); ^ ReferenceError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a '.js' file extension and '/app/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at file:///app/healthcheck.js:6:14 at ModuleJob.run (node:internal/modules/esm/module_job:263:25) at async ModuleLoader.import (node:internal/modules/esm/loader:540:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) Node.js v20.19.4 ```
kerem closed this issue 2026-02-27 07:17:33 +03:00
Author
Owner

@lileixuan commented on GitHub (Aug 27, 2025):

改下const http = require('http'); 换成import http from 'http';吧

<!-- gh-comment-id:3227457425 --> @lileixuan commented on GitHub (Aug 27, 2025): 改下const http = require('http'); 换成import http from 'http';吧
Author
Owner

@justlovemaki commented on GitHub (Aug 30, 2025):

已修复

<!-- gh-comment-id:3238893420 --> @justlovemaki commented on GitHub (Aug 30, 2025): 已修复
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#35
No description provided.