This issue showed up after trying to install Mongoose on my sapper project
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
<project path> is just my project path
I have a theory that this is caused by the bundling/minifying of the server code into a single file (__sapper__/dev/server.js), not sure how to fix it though.
My server rollup config, if it helps:
{
server: {
input: { server: config.server.input().server.replace(/\.js$/, '.ts') },
output: { ...config.server.output(), sourcemap },
plugins: [
replace({
'process.browser': false,
'process.env.NODE_ENV': JSON.stringify(mode),
'module.require': 'require',
}),
svelte({
generate: 'ssr',
dev,
preprocess,
}),
resolve({
dedupe: ['svelte'],
}),
commonjs({
sourceMap: !!sourcemap,
}),
typescript({
noEmitOnError: !dev,
sourceMap: !!sourcemap,
}),
json(),
],
external: [...Object.keys(pkg.dependencies).concat(
require('module').builtinModules || Object.keys(process.binding('natives')),
), 'saslprep'],
preserveEntrySignatures: 'strict'
},
}
the config is based mostly off this template