You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行node run.js命令报错:superCtor参数类型无效问题求助

问题与解决方案

问题详情

执行node run.js时触发类型错误,已执行npm install但问题未解决,错误信息如下:

node:util:249
throw new ERR_INVALID_ARG_TYPE('superCtor', 'Function', superCtor);
^

TypeError [ERR_INVALID_ARG_TYPE]: "superCtor" 参数必须是函数类型,接收到 undefined
    在 new NodeError (node:internal/errors:393:5)
    在 Object.inherits (node:util:249:11)
    在 Object.<anonymous> (/home/ansah/Documents/document/server/logs/winston-solr-transport.js:33:6)
    在 Module._compile (node:internal/modules/cjs/loader:1205:14)
    在 Module._extensions..js (node:internal/modules/cjs/loader:1259:10)
    在 Module.load (node:internal/modules/cjs/loader:1068:32)
    在 Module._load (node:internal/modules/cjs/loader:909:12)
    在 Module.require (node:internal/modules/cjs/loader:1092:19)
    在 require (node:internal/modules/cjs/helpers:103:18)
    在 Object.<anonymous> (/home/ansah/Documents/document/server/logs/log-init.js:10:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v19.1.0

解决办法

  • 排查winston-solr-transport兼容性
    错误根源是winston-solr-transport.js第33行调用util.inherits时,传入的父构造函数为undefined。这通常是因为该模块与Node.js v19.1.0不兼容,或是依赖的Winston版本不匹配。

    • 尝试安装适配Node.js v19的winston-solr-transport版本,比如:
      npm install winston-solr-transport@1.0.0 # 替换为实际兼容版本
      
    • 若找不到兼容版本,可降级Node.js至LTS版本(如v18.x),新版本Node.js可能移除了该模块依赖的旧API。
  • 修复模块代码中的构造函数导入
    打开/home/ansah/Documents/document/server/logs/winston-solr-transport.js,定位到第33行,检查父构造函数的导入是否正确。例如,如果是继承Winston的Transport,确保导入语句正确:

    const { Transport } = require('winston');
    util.inherits(SolrTransport, Transport);
    

    若Transport为undefined,说明Winston版本与该transport不兼容,需同步调整Winston版本。

  • 清理依赖缓存重新安装
    依赖缓存可能导致异常,执行以下命令彻底清理后重装:

    rm -rf node_modules package-lock.json
    npm install
    

内容的提问来源于stack exchange,提问作者ABHISHEK KUMAR YADAV

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 02:30:44