-
Notifications
You must be signed in to change notification settings - Fork 200
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 |
In case y'all missed it, the official recommendation from those working with @schickling to keep this project going is to temporarily switch to the contentlayer2 fork while they sort out the longer-term plan for continued support of this project. My fix for this issue was merged over there and released in 0.4.5 on the fork. 📝 I wrote some documentation to help anyone else moving over to the fork here. (timlrx/contentlayer2#18) See: Follow: |
* Migrate Unboxed repo modules into courses - Moved course-structure from Unboxed-Software/solana-course#384 to this repo using metadata.yml files - The "extending-solana-functionality" section was split into "connecting to offchain data" course and a separate "solana pay" single-lesson course. - 'versioned-transaction' was renamed to 'lookup-tables' - 'env-variables' was renamed to 'program configuration' - Tweak the Anchor CPI text to avoid assuming people have read the native CPI lesson. - Re-add burning and delegation exercises in a new lesson and lab - Fix internal relative links to the other lessons - Added images and fixed image links - Changed any link text that includes '//' to work around an apparent bug in https://github.com/remarkjs/remark-gfm - Add descriptions for all lessons - Use <Callout> for tips - Remove a few remaining instances of old airtable form - Remove some Phantom favoritism (replace with Ecosystem wallets page) - Add prerequisites lessons where necessary * Workaround a Callout bug. TODO: investigate and fix. * Fix bad description * Add image for unboxed * Minor fixes * Add course priority, so popular courses are shown first * More native-specific frontend parts into Native Development course * grammarly * Update ContentLayer to fix errors See contentlayerdev/contentlayer#495 * Lint * Get callouts working * Remove weird comment inside copy * Move this back to unboxed now we have 'with updates from...' * Avoid specific oracle recommendation and use ecosystem page for oracles * Fix: ensure course descriptions for within UI area * Tighten more descriptions to fit in UI size limit. * Fix a markdown table that was choking the parser * fix: use contentlayer2 * fix: broken pages * Change relative links to absolute links * Fix typo * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/mint-extensions/metadata.yml Co-authored-by: Nick Frostbutter <[email protected]> * Rename mint-extensions -> token-extensions-for-mints * Rename native-development -> native-onchain-development * Mention Anchor in metadata for onchain-development * Fix missing headings on program-security, add link to repo, use 'course' instead of module * Wrap 'completed the lab' in a callout --------- Co-authored-by: nickfrosty <[email protected]>
To run lint with CI, you need to run `contentlayer build` beforehand. However, when I run it, I get the following error: - contentlayerdev/contentlayer#495 Currently contentlayer is not maintained and a forked version of the community is maintained. This issue could not be resolved without a forked version, so I migrated.
To run lint with CI, you need to run `contentlayer build` beforehand. However, when I run it, I get the following error: - contentlayerdev/contentlayer#495 Currently contentlayer is not maintained and a forked version of the community is maintained. This issue could not be resolved without a forked version, so I migrated.
To run lint with CI, you need to run `contentlayer build` beforehand. However, when I run it, I get the following error: - contentlayerdev/contentlayer#495 Currently contentlayer is not maintained and a forked version of the community is maintained. This issue could not be resolved without a forked version, so I migrated.
Getting the same error in Bun and Node 22. I think I found the root cause for the bug. It's in diff --git a/lib/advanced/Cli.js b/lib/advanced/Cli.js
index b6946ca4ac6b2dd5d78598dfdef6caca7fcf5e33..41f84c271122007e819188bc0c8e0253069328ac 100644
--- a/lib/advanced/Cli.js
+++ b/lib/advanced/Cli.js
@@ -220,7 +220,7 @@ class Cli {
: noopCaptureActivator;
let exitCode;
try {
- exitCode = await activate(() => command.validateAndExecute().catch(error => command.catch(error).then(() => 0)));
+ exitCode = await activate(() => command.validateAndExecute().catch(error => command.catch(error)).then(() => 0));
}
catch (error) {
context.stdout.write(this.error(error, { colored, command }));
Without the patch, |
* Migrate Unboxed repo modules into courses - Moved course-structure from Unboxed-Software/solana-course#384 to this repo using metadata.yml files - The "extending-solana-functionality" section was split into "connecting to offchain data" course and a separate "solana pay" single-lesson course. - 'versioned-transaction' was renamed to 'lookup-tables' - 'env-variables' was renamed to 'program configuration' - Tweak the Anchor CPI text to avoid assuming people have read the native CPI lesson. - Re-add burning and delegation exercises in a new lesson and lab - Fix internal relative links to the other lessons - Added images and fixed image links - Changed any link text that includes '//' to work around an apparent bug in https://github.com/remarkjs/remark-gfm - Add descriptions for all lessons - Use <Callout> for tips - Remove a few remaining instances of old airtable form - Remove some Phantom favoritism (replace with Ecosystem wallets page) - Add prerequisites lessons where necessary * Workaround a Callout bug. TODO: investigate and fix. * Fix bad description * Add image for unboxed * Minor fixes * Add course priority, so popular courses are shown first * More native-specific frontend parts into Native Development course * grammarly * Update ContentLayer to fix errors See contentlayerdev/contentlayer#495 * Lint * Get callouts working * Remove weird comment inside copy * Move this back to unboxed now we have 'with updates from...' * Avoid specific oracle recommendation and use ecosystem page for oracles * Fix: ensure course descriptions for within UI area * Tighten more descriptions to fit in UI size limit. * Fix a markdown table that was choking the parser * fix: use contentlayer2 * fix: broken pages * Change relative links to absolute links * Fix typo * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/connecting-to-offchain-data/verifiable-randomness-functions.md Co-authored-by: Nick Frostbutter <[email protected]> * Update content/courses/mint-extensions/metadata.yml Co-authored-by: Nick Frostbutter <[email protected]> * Rename mint-extensions -> token-extensions-for-mints * Rename native-development -> native-onchain-development * Mention Anchor in metadata for onchain-development * Fix missing headings on program-security, add link to repo, use 'course' instead of module * Wrap 'completed the lab' in a callout --------- Co-authored-by: nickfrosty <[email protected]>
@nmn is there a solution for this even I am getting this error in Bun and Node 22. |
@scshiv29-dev I literally shared my solution. I used |
@nmn yea I was not familiar with package patching and so I asked . I shifted to contentlayer2 . |
The error is non-fatal and still generates the documents.
Contentlayer config:
The text was updated successfully, but these errors were encountered: