fuma-nama / fumadocs

The beautiful docs framework for Next.js. Alternative to Nextra
https://fumadocs.vercel.app
MIT License
1.43k stars 83 forks source link

Module Loading Errors in Workspace Project #444

Closed changeelog closed 3 months ago

changeelog commented 3 months ago

To Reproduce

I wish I knew. After forking the repository changeelog/fumadocs (https://github.com/changeelog/fumadocs) and running pnpm install, attempting to start the development server with pnpm dev results in multiple errors including:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\fm\fumadocs\examples\next-mdx\node_modules\fumadocs-mdx\dist\config.mjs'
Unable to determine why task exited
pnpm install
Scope: all 17 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +1227
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
Progress: resolved 1227, reused 1226, downloaded 0, added 1227, done

devDependencies:
+ @changesets/cli 2.27.5
+ @typescript-eslint/eslint-plugin 7.12.0
+ @typescript-eslint/parser 7.12.0
+ @vercel/style-guide 6.0.0
+ concurrently 8.2.2
+ eslint 8.57.0
+ eslint-plugin-tailwindcss 3.17.3
+ prettier 3.3.1
+ rimraf 5.0.7
+ tsup 8.1.0
+ turbo 2.0.3
+ typescript 5.4.5
+ vitest 1.6.0

After running pnpm dev I get

pnpm dev

> root@0.1.0 dev D:\fm\fumadocs
> turbo run dev

• Packages in scope: create-fumadocs-app, docs, eslint-config-custom, example-contentlayer, example-i18n, example-next-mdx, example-versions, fumadocs-contentlayer, fumadocs-core, fumadocs-docgen, fumadocs-mdx, fumadocs-openapi, fumadocs-twoslash, fumadocs-typescript, fumadocs-ui, tsconfig
• Running dev in 16 packages
• Remote caching disabled
┌ create-fumadocs-app#dev > cache bypass, force executing 70b85b85cc80aa64 
│ 
│ > create-fumadocs-app@12.0.1 dev D:\fm\fumadocs\packages\create-app      
│ > tsup --watch
│ 
│ version updated
│ CLI Building entry: ./src/index.ts, ./src/create-app.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI tsup v8.1.0
│ CLI Using tsup config: D:\fm\fumadocs\packages\create-app\tsup.config.ts 
│ CLI Running in watch mode
│ CLI Target: node18
│ ESM Build start
│ ESM dist\index.js          2.54 KB
│ ESM dist\create-app.js     69.00 B
│ ESM dist\chunk-D47BRJXS.js 5.02 KB
│ ESM ⚡️ Build success in 3626ms
│ CLI Watching for changes in "."
│ CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
└────>
┌ docs#dev > cache bypass, force executing 177c59df946dc418
│
│ > docs@0.1.3 dev D:\fm\fumadocs\apps\docs
│ > next dev
│
│ node:internal/modules/esm/resolve:263
│     throw new ERR_MODULE_NOT_FOUND(
│           ^
│
│ Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\fm\fumadocs\apps\docs\node_modules\fumadocs-mdx\dist\config.mjs' imported
│ from D:\fm\fumadocs\apps\doc
│ s\next.config.js
│     at finalizeResolution (node:internal/modules/esm/resolve:263:11)
│     at moduleResolve (node:internal/modules/esm/resolve:908:10)
│     at defaultResolve (node:internal/modules/esm/resolve:1131:11)
│     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
│     at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
│     at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
│     at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
│     at link (node:internal/modules/esm/module_job:84:36) {
│   code: 'ERR_MODULE_NOT_FOUND',
│   url: 'file:///D:/fm/fumadocs/apps/docs/node_modules/fumadocs-mdx/dist/config.mjs'
│ }
│
│ Node.js v21.6.1
│  ELIFECYCLE  Command failed with exit code 1.
└────>
┌ example-contentlayer#dev > cache bypass, force executing bac9ba4858e650a0
│
└────>
┌ example-i18n#dev > cache bypass, force executing 23300a283024d387
│
└────>
┌ example-next-mdx#dev > cache bypass, force executing f74f0ff82f68a69f
│
│ > example-next-mdx@0.0.0 dev D:\fm\fumadocs\examples\next-mdx
│ > next dev
│ 
│ node:internal/modules/esm/resolve:263
│     throw new ERR_MODULE_NOT_FOUND(
│           ^
│
│ Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\fm\fumadocs\examples\next-mdx\node_modules\fumadocs-mdx\dist\config.mjs' i
│ mported from D:\fm\fumadocs\
│ examples\next-mdx\next.config.mjs
│     at finalizeResolution (node:internal/modules/esm/resolve:263:11)
│     at moduleResolve (node:internal/modules/esm/resolve:908:10)
│     at defaultResolve (node:internal/modules/esm/resolve:1131:11)
│     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
│     at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
│     at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
│     at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
│     at link (node:internal/modules/esm/module_job:84:36) {
│   code: 'ERR_MODULE_NOT_FOUND',
│   url: 'file:///D:/fm/fumadocs/examples/next-mdx/node_modules/fumadocs-mdx/dist/config.mjs'
│ }
│
│ Node.js v21.6.1
│  ELIFECYCLE  Command failed with exit code 1.
│
│ command finished with error: command (D:\fm\fumadocs\examples\next-mdx) C:\Users\женя\AppData\Roaming\npm\pnpm.cmd run dev exit
│ ed (1)
└────>
┌ fumadocs-contentlayer#dev > cache bypass, force executing a38f960f8576b9d8
│
│ > fumadocs-contentlayer@1.1.31 dev D:\fm\fumadocs\packages\contentlayer
│ > tsup --watch
│
│ CLI Building entry: src/index.ts, src/configuration.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI tsup v8.1.0
│ CLI Using tsup config: D:\fm\fumadocs\packages\contentlayer\tsup.config.ts
│ CLI Running in watch mode
│ CLI Target: es6
│ ESM Build start
│ ESM dist\configuration.js  2.94 KB
│ ESM dist\index.js          434.00 B
│ ESM dist\chunk-N3ETBM74.js 900.00 B
│ ESM ⚡️ Build success in 1959ms
│ CLI Watching for changes in "."
│ CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
│ DTS Build start
└────>
┌ fumadocs-core#dev > cache bypass, force executing 26668ee6a2dff2f9
│
│ > fumadocs-core@12.0.1 dev D:\fm\fumadocs\packages\core
│ > tsup --watch
│
│ CLI Building entry: src/toc.tsx, src/link.tsx, src/sidebar.tsx, src/breadcrumb.tsx, src/dynamic-link.tsx, src/server/index.ts,
│ src/source/index.ts, src/mdx
│ -plugins/index.ts, src/search/client.ts, src/search-algolia/client.ts, src/search/shared.ts, src/search/server.ts, src/search-a
│ lgolia/server.ts, src/middle
│ ware.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI tsup v8.1.0
│ CLI Using tsup config: D:\fm\fumadocs\packages\core\tsup.config.ts
│ CLI Running in watch mode
│ CLI Target: es6
│ ESM Build start
│ DTS Build start
└────>
┌ fumadocs-docgen#dev > cache bypass, force executing 682aae0916a556cd
│
│ > fumadocs-docgen@1.0.2 dev D:\fm\fumadocs\packages\doc-gen
│ > tsup --watch
│ 
│ CLI Building entry: src/index.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI tsup v8.1.0
│ CLI Using tsup config: D:\fm\fumadocs\packages\doc-gen\tsup.config.ts
│ CLI Running in watch mode
│ CLI Target: es6
│ ESM Build start
│ DTS Build start
│ ESM dist\index.js 5.25 KB
│ ESM ⚡️ Build success in 2177ms
│ CLI Watching for changes in "."
│ CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
└────>
┌ fumadocs-mdx#dev > cache bypass, force executing 3d47710fce35416e
│
└────>
┌ fumadocs-openapi#dev > cache bypass, force executing 6b0149ccca0952e7
│
│ > fumadocs-openapi@2.0.3 dev D:\fm\fumadocs\packages\openapi
│ > tsup --watch
│
│ CLI Building entry: ./src/index.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI tsup v8.1.0
│ CLI Using tsup config: D:\fm\fumadocs\packages\openapi\tsup.config.ts
│ CLI Running in watch mode
│ CLI Target: node18
│ ESM Build start
│ DTS Build start
│ ESM dist\index.js 15.18 KB
│ ESM ⚡️ Build success in 3566ms
│ CLI Watching for changes in "."
│ CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
└────>
┌ fumadocs-twoslash#dev > cache bypass, force executing 9df6aaadbedd5682
│
│ > fumadocs-twoslash@1.0.3 dev D:\fm\fumadocs\packages\twoslash
│ > tsup --watch
│
│ CLI Building entry: src/index.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI Using tsup config: D:\fm\fumadocs\packages\twoslash\tsup.config.ts
│ CLI Target: es6
│ ESM dist\index.js 3.29 KB
│ ESM ⚡️ Build success in 1372ms
│ CLI Watching for changes in "."
│ CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
│ DTS Build start
└────>
┌ fumadocs-typescript#dev > cache bypass, force executing 643be739319b5b3a
│
│ > tsup --watch
│
│ CLI Building entry: src/index.ts, src/ui/index.ts
│ CLI Using tsconfig: tsconfig.json
│ CLI tsup v8.1.0
│ CLI Using tsup config: D:\fm\fumadocs\packages\typescript\tsup.config.ts
│ CLI Running in watch mode
│ CLI Target: es6
│ ESM Build start
│ DTS Build start
│ ESM dist\index.js          3.39 KB
│ ESM dist\ui\index.js       1.07 KB
│ ESM dist\chunk-5NJLG4AV.js 5.42 KB
│ ESM ⚡️ Build success in 3150ms
│ CLI Watching for changes in "."
│ CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
└────>
┌ fumadocs-ui#dev > cache bypass, force executing 00b420d20d3fccf8
│
│ > fumadocs-ui@12.0.1 dev D:\fm\fumadocs\packages\ui
│ > concurrently "pnpm dev:layout" "pnpm dev:tailwind"
│
│ [1]
│ [1] > fumadocs-ui@12.0.1 dev:tailwind D:\fm\fumadocs\packages\ui
│ [1]
│ [0]
│ [0] > fumadocs-ui@12.0.1 dev:layout D:\fm\fumadocs\packages\ui
│ [0] > tsup --watch
│ [0]
│ [0] pnpm dev:layout exited with code 3221225786
└────>
  │ to determine why task exited,unable to determine why task exited,unable to determine why task exited,unable to determine why task exited,unable to     
  │ determine why task exited,unable to determine why task exited

 ELIFECYCLE  Command failed with exit code 1.

Current vs. Expected behavior

Expected Behavior

The development environment should start without issues, and all packages should build successfully.

Actual Behavior

Module Not Found Errors:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\fm\fumadocs\examples\next-mdx\node_modules\fumadocs-mdx\dist\config.mjs'

Errors During Task Execution:

Unable to determine why task exited

Also next info didn't work for me when deps where installed, it ran when I deleted pnpm-lock.yaml and node_modules folder. I've tried running the exact same steps on two of my machines and still got the exact same thing.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Home
  Available memory (MB): 7992
  Available CPU cores: 4
Binaries:
  Node: 21.6.1
  npm: N/A
  Yarn: N/A
  pnpm: 8.15.1
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

Deleting pnpm-lock.yaml and node_modules directory and then reinstalling deps with pnpm install doesn't seem to solve the issue

fuma-nama commented 3 months ago

You have to build the dependencies first to generate types (pnpm run build --filter=./packages/*), then run pnpm run dev --filter=docs to run the dev server

fuma-nama commented 3 months ago

This is a Turborepo problem and their recommended approach is to build them before running in watch mode (because in watch mode, the process won't be interrupted after the first build. There's no way to detect either the build is finished and start the dev server of a workspace when only its dependencies are built)

changeelog commented 3 months ago

Oh, yeah, I've completely forgot about the Turborepo thing, working fine for now, thanks

changeelog commented 3 months ago

Could be closed now I guess