shuding / nextra-docs-template

Nextra docs template
https://nextra-docs-template.vercel.app
MIT License
1.01k stars 578 forks source link

Getting error while trying to run the forked project. #21

Open rexx-p opened 1 year ago

rexx-p commented 1 year ago

$ node -v v16.14.2

$ yarn build yarn run v1.22.19 $ next build info - Linting and checking validity of types
unhandledRejection file:///C:/Users/APPWRK/Desktop/rethink-2.0/rethink-next-docs-template/node_modules/nextra/dist/file-system.mjs:2 import { findPagesDir, existsSync } from "next/dist/lib/find-pages-dir.js"; ^^^^^^^^^^ SyntaxError: Named export 'existsSync' not found. The requested module 'next/dist/lib/find-pages-dir.js' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'next/dist/lib/find-pages-dir.js'; const { findPagesDir, existsSync } = pkg;

at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)

error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Min5407 commented 1 year ago

@rexx-p I have solved the issue. Change yournext.config.js file to next.config.mjs and add the example code below.

import nextra from "nextra";
const withNextra = nextra({
  theme: "nextra-theme-docs",
  themeConfig: "./theme.config.tsx",
  staticImage: true,
  latex: true,
  flexsearch: {
    codeblock: false,
  },
});
export default withNextra();
barakcodes commented 1 year ago

This issue helped fix it for me. Just pinning the next js version to 13.3.0. Thanks to @Min5407

rexx-p commented 1 year ago

Thank you @Min5407

ionhhworkers commented 4 days ago

It's worth noting that if you still have problems running the template, you should rename this file:

"Error: Support of "_meta.json" was removed, use "_meta.{js,jsx,ts,tsx}""

With the following refactor:

import { DocsThemeConfig } from "nextra-theme-docs";

export default {
  index: "Introduction",
  another: "Another Page",
  advanced: "Advanced (A Folder)",
  about: {
    title: "About",
    type: "page",
  },
  contact: {
    title: "Contact ↗",
    type: "page",
    href: "https://twitter.com/shuding_",
    newWindow: true,
  },
} as DocsThemeConfig;