vercel错误没有这样的文件或目录,打开'/var/task/node_modules/shiki/themes/one-dark-pro.json'

问题描述 投票:0回答:1
import { serialize } from 'next-mdx-remote/serialize';
import readingTime from 'reading-time';
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypePrettyCode from 'rehype-pretty-code';

/** @type {import('rehype-pretty-code').Options} */
const options = {
    theme: 'one-dark-pro',
    onVisitLine(node: any) {
        if (node.children.length === 0) {
            node.children = [{ type: 'text', value: ' ' }];
        }
    },
    onVisitHighlightedLine(node: any) {
        node.properties.className.push('line--highlighted');
    },
    onVisitHighlightedWord(node: any) {
        node.properties.className = ['word--highlighted'];
    },
};

export async function mdxToHtml(source: any) {
    const mdxSource = await serialize(source, {
        mdxOptions: {
            remarkPlugins: [remarkGfm],
            rehypePlugins: [
                rehypeSlug,
                [rehypePrettyCode, options],
                [
                    rehypeAutolinkHeadings,
                    {
                        properties: {
                            className: ['anchor'],
                        },
                    },
                ],
            ],
            format: 'mdx',
        },
    });

    return {
        html: mdxSource,
        wordCount: source.split(/\s+/gu).length,
        readingTime: readingTime(source).text,
    };
}

在构建页面时在 vercel 日志中出现此错误,并且我正在使用应用程序路由器

ENOENT: no such file or directory, open '/var/task/node_modules/shiki/themes/one-dark-pro.json'

我还安装了 shiki 软件包,但在 vercel 日志上会收到相同的错误消息

当我构建代码时,它将成功编译,但是当我通过像此函数 revalidatePath 这样的 api 使用 ondemand revalidate 时,它会在 vercel 日志中给出错误

next.js vercel nextjs13 next
1个回答
0
投票

你的问题找到解决办法了吗,我也遇到了同样的问题。

© www.soinside.com 2019 - 2024. All rights reserved.