New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contentlayer build
produces TypeError: The "code" argument must be of type number. Received an instance of Object
#495
Comments
I just ran a build on Vercel and it seems like there is no error there, not sure what's going on. |
Thanks for opening this issue. Can you please provide minimal a reproduction repo with instructions how to reproduce the problem you're experiencing? Thank you! |
|
Seems like something was deprecated on Node 19, and removed in Node 20, which is where the issue lies.
|
@Xenfo, hey, did you solve this somehow? |
No, it’s annoying but I just let it happen since everything is still generated properly. |
Same here - issue occuring on Node v20.5.0. DOES NOT occur with Node 18.17. |
I have the same issue Node v20.5.1 |
Same problem here. Not sure if there is anything to do about it. |
This is related to Node Deprecation DEP0164 (process.exit(code), process.exitCode coercion to integer. This will offer a deprecation warning on Node 19.x.x, but as of Node 20.0.0, it will throw an error. In relation to contentlayer, the CLI is attempting to assign a resulting object with Within CLI.js function It is worth noting that this doesn't affect functionality of CLI commands. It just impacts the ability for CLI commands to report a valid exit code, so it will always be assumed to be an error. |
Hello, same problem here. Thank you all for your investigations. |
Me too. I just upgrade my node to |
No, don't worry. It's just very confusing. |
So it seems the I suspect this has gone unnoticed for so long due to the now legacy Here's what the patch looks like using .yarn/patches/@contentlayer-cli-npm-0.3.3-e932de1bc4.patch diff --git a/dist/commands/BuildCommand.js b/dist/commands/BuildCommand.js
index 1cc67c8c9b28622c2391c1da70754ab99dcc35d6..27b35388b71bc8cb64463329e9b1ef251b3382b4 100644
--- a/dist/commands/BuildCommand.js
+++ b/dist/commands/BuildCommand.js
@@ -4,7 +4,7 @@ import { BaseCommand } from './_BaseCommand.js';
class BuildCommand extends BaseCommand {
constructor() {
super(...arguments);
- this.executeSafe = () => pipe(this.clearCacheIfNeeded(), T.chain(() => core.getConfig({ configPath: this.configPath })), T.tap((config) => (config.source.options.disableImportAliasWarning ? T.unit : T.fork(core.validateTsconfig))), T.chain((config) => core.generateDotpkg({ config, verbose: this.verbose })), T.tap(core.logGenerateInfo), OT.withSpan('@contentlayer/cli/commands/BuildCommand:executeSafe'));
+ this.executeSafe = () => pipe(this.clearCacheIfNeeded(), T.chain(() => core.getConfig({ configPath: this.configPath })), T.tap((config) => (config.source.options.disableImportAliasWarning ? T.unit : T.fork(core.validateTsconfig))), T.chain((config) => core.generateDotpkg({ config, verbose: this.verbose })), T.tap(core.logGenerateInfo), T.map(() => 0), OT.withSpan('@contentlayer/cli/commands/BuildCommand:executeSafe'));
}
}
BuildCommand.paths = [['build']]; |
still getting this error |
also just got this error |
Issue goes away on node version 18 |
The error is non-fatal and still generates the documents.
Contentlayer config:
The text was updated successfully, but these errors were encountered: