Skip to content

contentlayer build produces TypeError: The "code" argument must be of type number. Received an instance of Object #495

@samchouse

Description

@samchouse

The error is non-fatal and still generates the documents.

Generated 9 documents in .contentlayer
TypeError: The "code" argument must be of type number. Received an instance of Object
    at process.set [as exitCode] (node:internal/bootstrap/node:124:9)
    at Cli.runExit (/home/xenfo/projects/website/node_modules/clipanion/lib/advanced/Cli.js:232:26)
    at run (file:///home/xenfo/projects/website/node_modules/@contentlayer/cli/src/index.ts:39:3)
    at main (/home/xenfo/projects/website/node_modules/contentlayer/bin/cli.cjs:5:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Contentlayer config:

import { defineDocumentType, makeSource } from 'contentlayer/source-files';

export const Post = defineDocumentType(() => ({
  name: 'Post',
  filePathPattern: 'posts/*.mdx',
  contentType: 'mdx',
  fields: {
    title: {
      type: 'string',
      description: 'The title of the post',
      required: true
    },
    description: {
      type: 'string',
      description: 'The description of the post',
      required: true
    },
    publishedOn: {
      type: 'date',
      description: 'The publishing date of the post',
      required: true
    },
    editedOn: {
      type: 'date',
      description: 'The editing date of the post',
      required: true
    },
    status: {
      type: 'enum',
      description: 'The status of the post',
      options: ['draft', 'published', 'edited'],
      required: true
    }
  },
  computedFields: {
    slug: {
      type: 'string',
      description: 'The slug of the post',
      resolve: (post) => post._raw.sourceFileName.replace(/\.mdx?$/, '')
    }
  }
}));

export default makeSource({
  contentDirPath: 'data',
  contentDirExclude: ['themes'],
  documentTypes: [Post]
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions