Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERR_MODULE_NOT_FOUND] when consuming custom theme #4529

Open
4 tasks done
silvester-pari opened this issue Jan 28, 2025 · 2 comments
Open
4 tasks done

[ERR_MODULE_NOT_FOUND] when consuming custom theme #4529

silvester-pari opened this issue Jan 28, 2025 · 2 comments
Labels
build Related to the build system

Comments

@silvester-pari
Copy link

Describe the bug

When creating a custom theme following the docs, and then installing it in another VitePress page, it throws an error at docs:build (working fine on docs:dev:

Cannot find module '/home/silvester/Desktop/temp3/page/node_modules/vitepress/dist/client/theme-default/without-fonts' imported from /home/silvester/Desktop/temp3/page/node_modules/vitepress/dist/client/theme-default/index.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/silvester/Desktop/temp3/page/node_modules/vitepress/dist/client/theme-default/without-fonts' imported from /home/silvester/Desktop/temp3/page/node_modules/vitepress/dist/client/theme-default/index.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:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
    at link (node:internal/modules/esm/module_job:95:36)
import MyTheme from 'my-theme';

export default {
  extends: MyTheme,
}

Reproduction

Reproduction repository: https://github.com/silvester-pari/vitepress-custom-theme-error
(Follow instructions in Readme)

Expected behavior

When extending a Theme based on the DefaultTheme, it should work.

System Info

System:
    OS: Linux 6.8 Linux Mint 22 (Wilma)
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 5.49 GB / 15.39 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.18.1 - ~/.nvm/versions/node/v20.18.1/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.1/bin/npm
  Browsers:
    Chrome: 131.0.6778.204

Additional context

No response

Validations

@silvester-pari silvester-pari added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 28, 2025
@brc-dd
Copy link
Member

brc-dd commented Jan 28, 2025

Add your theme's package name to vite.ssr.noExternal in vitepress config.

It needs fixing on our part to work, but it might take time and noExternal should work fine in meanwhile.

@brc-dd brc-dd added build Related to the build system and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jan 28, 2025
@silvester-pari
Copy link
Author

Thank you, I can confirm it works with:

// page/.vitepress/config.mjs
vite: {
  ssr: {
    noExternal: ['my-theme']
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to the build system
Projects
None yet
Development

No branches or pull requests

2 participants