TypeError [ERR_INVALID_ARG_TYPE]:“superCtor”参数必须是函数类型。收到未定义

mat*_*mat 6 rollup mongoose mongodb sapper

尝试在我的工兵项目上安装 Mongoose 后出现此问题

util.js:157
    throw new ERR_INVALID_ARG_TYPE('superCtor', 'Function', superCtor);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "superCtor" argument must be of type function. Received undefined
    at Object.inherits (util.js:157:11)
    at Object.<anonymous> (<project path>\__sapper__\dev\server\server.js:140600:8)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}
> Server crashed
Run Code Online (Sandbox Code Playgroud)

<project path> 只是我的项目路径

我有一个理论,这是由于将服务器代码捆绑/缩小到单个文件(__sapper__/dev/server.js)中引起的,但不确定如何修复它。

我的服务器汇总配置,如果有帮助的话:

util.js:157
    throw new ERR_INVALID_ARG_TYPE('superCtor', 'Function', superCtor);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "superCtor" argument must be of type function. Received undefined
    at Object.inherits (util.js:157:11)
    at Object.<anonymous> (<project path>\__sapper__\dev\server\server.js:140600:8)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}
> Server crashed
Run Code Online (Sandbox Code Playgroud)

配置主要基于此模板

McT*_*fik 0

不确定这是否会对您有帮助,因为我不知道 Mangose 或 Sapper 是什么,但我在@google-cloud/storage导入时遇到了此错误。

解决方案是不将其捆绑在一起:

nodeResolve({ 
  preferBuiltins: true, 
  browser: false, 
  resolveOnly: ['@google-cloud/storage'] 
}),
Run Code Online (Sandbox Code Playgroud)