shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.3k stars 1.24k forks source link

Unable to build repo: Cannot find module 'node:path' or its corresponding type declarations #2701

Open asimaranov opened 7 months ago

asimaranov commented 7 months ago

When I clone repo and run pnpm install, pnpm build, it fails with this error

│ [NEXTRA-CLIENT] ESM dist/icons/word-wrap.js              449.00 B
│ [NEXTRA-CLIENT] ESM dist/icons/x.js                      671.00 B
│ [NEXTRA-CLIENT] ESM ⚡️ Build success in 96ms
│ [NEXTRA-ESM] DTS Build start
│ [NEXTRA-CLIENT] DTS Build start
│ [NEXTRA-TYPES] DTS Build start
│ src/constants.ts(1,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ Error: error occured in dts build
│     at Worker.<anonymous> (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/index.js:2294:26)
│     at Worker.emit (node:events:517:28)
│     at MessagePort.<anonymous> (node:internal/worker:243:53)
│     at [nodejs.internal.kHybridDispatch] (node:internal/event_target:757:20)
│     at exports.emitMessage (node:internal/per_context/messageport:23:28)
│ [NEXTRA-TYPES] DTS Build error
│ RollupError: Failed to compile. Check the logs above.
│     at error (/Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:210:30)
│     at Object.error (/Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:23975:20)
│     at Object.error (/Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:23220:42)
│     at generateDtsFromTs (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:7512:22)
│     at /Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:7519:59
│     at _nullishCoalesce (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:1:198)
│     at Object.transform (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:7519:18)
│     at /Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:24176:40
│ src/compile.ts(1,31): error TS2307: Cannot find module 'node:module' or its corresponding type declarations.
│ src/compile.ts(2,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ [NEXTRA-ESM] DTS Build error
│ RollupError: Failed to compile. Check the logs above.
│     at error (/Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:210:30)
│     at Object.error (/Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:23975:20)
│     at Object.error (/Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:23220:42)
│     at generateDtsFromTs (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:7512:22)
│     at /Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:7519:59
│     at _nullishCoalesce (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:1:198)
│     at Object.transform (/Users/andrey/projects/nextra/node_modules/.pnpm/tsup@7.2.0_postcss@8.4.31_typescript@5.3.3/node_modules/tsup/dist/rollup.js:7519:18)
│     at /Users/andrey/projects/nextra/node_modules/.pnpm/rollup@3.9.1/node_modules/rollup/dist/shared/rollup.js:24176:40
│ src/constants.ts(1,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ src/loader.ts(1,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ src/utils.ts(1,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ src/plugin.ts(1,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ src/plugin.ts(2,27): error TS2307: Cannot find module 'node:util' or its corresponding type declarations.
│ src/plugin.ts(69,36): error TS7006: Parameter 'f' implicitly has an 'any' type.
│ src/mdx-plugins/remark-static-image.ts(1,18): error TS2307: Cannot find module 'node:path' or its corresponding type declarations.
│ src/mdx-plugins/remark-replace-imports.ts(1,31): error TS2307: Cannot find module 'node:module' or its corresponding type declarations.

Node version: ➜ nextra git:(main) node -v v18.18.2 Pnpm version: pnpm -v 8.15.1

What may be the problem?

ezbeazy commented 1 month ago

Had issues as well. I think you have to build the packages separately (packages/nextra, packages/nextra-theme-docs, packages/nextra-theme-blog). I tried the build scripts they didn't work for me. I also had to run pnpm install within the example before running pnpm dev

node:internal/modules/esm/resolve:265
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/ezb/Sites/nextra/examples/blog/node_modules/nextra/dist/index.js' imported from /Users/ezb/Sites/nextra/examples/blog/next.config.js
    at finalizeResolution (node:internal/modules/esm/resolve:265:11)
    at moduleResolve (node:internal/modules/esm/resolve:933:10)
    at defaultResolve (node:internal/modules/esm/resolve:1157:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Users/ezb/Sites/nextra/examples/blog/node_modules/nextra/dist/index.js'
}

Node.js v20.15.0
 ELIFECYCLE  Command failed with exit code 1.