Skip to content

Build error: [commonjs--resolver] Missing "#" specifier when using href="#" in SVG tags #34858

Closed as not planned
vuejs/core
#14756

Description

@miguel-siqueira-reis

Environment

│ ╭── Nuxt project info (copied to clipboard) ───────────╮
│ │ │
│ │ Operating system macOS 25.3.0 │
│ │ CPU Apple M1 Pro (10 cores) │
│ │ Node.js version v24.3.0 │
│ │ nuxt/cli version 3.34.0 │
│ │ Package manager npm 11.4.2 │
│ │ Nuxt version 4.4.2 │
│ │ Nitro version 2.13.3 │
│ │ Builder vite 7.3.2 │
│ │ Config compatibilityDate, devtools │
│ │ Modules - │
│ │ │
│ ╰──────────────────────────────────────────────────────╯

Reproduction

Reproduction repository: https://github.com/miguel-siqueira-reis/nuxt-svg-hashtag-bug

Steps to reproduce

  1. Clone the repo.
  2. Run npm install.
  3. Run npx nuxi build.
  4. See the error: [commonjs--resolver] Missing "#" specifier in "nuxt" package.

Describe the bug

When using a literal # in an SVG attribute (like href="#" or xlink:href="#") inside a Vue component, the Nuxt build fails.

The Vite/Rollup bundler incorrectly attempts to resolve the # character as a Node.js Subpath Import (specifier) instead of treating it as a static SVG fragment identifier. Since Nuxt uses the # prefix for internal aliases (e.g., #app), the resolver throws a Missing "#" specifier error.

Additional context

This only happens during the production build (nuxi build), not in development mode. It seems the static analysis of the SVG template is too aggressive, confusing standard SVG syntax with Nuxt's internal module mapping.

Temporary Workaround:
Using Vue's dynamic binding :href="'#'" bypasses the static analysis and solves the issue, but it shouldn't be necessary for valid SVG code.

Logs

> build
> nuxt build

┌  Building Nuxt for production...
│
●  Nuxt 4.4.2 (with Nitro 2.13.3, Vite 7.3.2 and Vue 3.5.33)
│
●  Nitro preset: node-server
ℹ Building client...                                                 11:11:37
ℹ vite v7.3.2 building client environment for production...          11:11:37

[11:11:37]  WARN  [plugin nuxt:module-preload-polyfill] Sourcemap is likely to be incorrect: a plugin (nuxt:module-preload-polyfill) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

ℹ ✓ 44 modules transformed.                                          11:11:37

 ERROR  ✗ Build failed in 210ms                                       11:11:37

│
■  Nuxt build error: Error: [commonjs--resolver] Missing "#" specifier in "nuxt" package

Activity

  1. added theissue type on Apr 23, 2026
  2. danielroe commented on Apr 23, 2026

    @danielroe
    Member

    this is an upstream vue issue - see playground.

    I've opened vuejs/core#14756 to resolve

  3. added
    upstream
    and removed on Apr 28, 2026
  4. danielroe commented on Apr 28, 2026

    @danielroe
    Member

    closed as upstream

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

    upstream

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions