Skip to content

Nuxt3 Use npm run build "default" is not exported by "node_modules/highlight.js/lib/index.js" #4246

@AABBCC-cloud

Description

@AABBCC-cloud

npm run build

build
nuxt build

Nuxt 3.16.2 with Nitro 2.11.8 nuxi 16:05:39
ℹ Building for Nitro preset: node-server nuxi 16:05:42
ℹ Building client... 16:05:50
ℹ vite v6.2.5 building for production... 16:05:50
ℹ ✓ 2339 modules transformed. 16:06:03

ERROR ✗ Build failed in 12.82s 16:06:03

[ nuxi 16:06:03] ERROR Nuxt Build Error: node_modules/highlight.js/es/index.js (2:7): "default" is not exported by "node_modules/highlight.js/lib/index.js", imported by "node_modules/highlight.js/es/index.js".
file: C:/Users/xkgoo/Desktop/starter/node_modules/highlight.js/es/index.js:2:7

1: // https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards
2: import HighlightJS from '../lib/index.js';
^
3: export { HighlightJS };
4: export default HighlightJS;

Activity

joshgoebel

joshgoebel commented on Apr 27, 2025

@joshgoebel
Member

If you look at our sources you'll see we do export default from lib. This works fine for node... maybe file an issue with nuxt?


You may want to try the CDN assets which include pure ES6 builds though.

https://www.npmjs.com/package/@highlightjs/cdn-assets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @joshgoebel@AABBCC-cloud

        Issue actions

          Nuxt3 Use npm run build "default" is not exported by "node_modules/highlight.js/lib/index.js" · Issue #4246 · highlightjs/highlight.js