Nodered in Docker run issue
- 主要語言
- TypeScript
- 星號
- 344
- 分支
- 66
- PR 合併指標
- 30 天內沒有已合併 PR
描述
I need id3js in Nodered inside Docker container.
I installed id3 running `npm i -S id3js` in /data directory. According to Nodered manual (https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules)
[](https://nodered.org/docs/user-guide/writing-functions#loading-additional-modules) I have added `id3js:require('id3js')` to **functionGlobalContext** section. After container retsart I have this on logs:
```
> node-red-docker@1.0.3 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
Error loading settings file: /data/settings.js
/data/node_modules/id3js/lib/id3.js:1
import { parse } from './id3Tag.js';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/data/settings.js:220:8)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
這個錯誤表示 id3js 模組使用了 ES 模組語法 (import),而 Node-RED Docker 環境沒有正確處理該語法。檢查模組的 package.json,確認其中是否指定了 type: 'module' 或使用了 .mjs 副檔名。查看模組的建置方式,以及它是否提供 CommonJS 版本。這個問題與 ES 模組和預期使用 CommonJS 的 Node-RED functionGlobalContext 之間的相容性有關。先檢查 lib/id3.js 檔案和建置流程,接著在簡單的 Node.js 指令碼中測試匯入它,以確認是否會發生相同的錯誤。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- docker, javascript, node.js
- 領域
- cli, tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100