Skip to content

Nitro 2: node-externals constructs a trailing-slash package specifier, triggering DEP0155 for @vue/shared #4611

Closed as not planned

Description

@lvzhenbo

Environment

  • OS: Windows
  • Node.js: 24.19.0
  • Package manager: pnpm 12.3.4
  • Nuxt: 4.5.2
  • Nitro / nitropack: 2.13.4
  • Vue / @vue/shared: 3.5.42
  • mlly: 1.8.2
  • exsolve: 1.1.1
  • Build preset: node-server
  • Compatibility date: 2025-12-21

Relevant configuration:

export default defineNuxtConfig({
  compatibilityDate: '2025-12-21',
  nitro: {
    experimental: {
      websocket: true,
    },
  },
})

### Reproduction

he warning occurs during the Nitro server build phase of an existing Nuxt application.

To capture the stack trace, run the build with deprecation tracing enabled. In PowerShell:

```powershell
$env:NODE_OPTIONS = '--trace-deprecation'
pnpm build

I do not currently have a public minimal reproduction repository. However, I traced the warning in the actual build and independently reproduced the dependency-resolution sequence using the installed dependencies.

The isolated sequence is:

// vueFile is the resolved absolute path to:
// @vue/shared/dist/shared.esm-bundler.js

const subpath = await lookupNodeModuleSubpath(vueFile)
// "./"

const specifier = join('@vue/shared', subpath)
// "@vue/shared/"

resolveModuleURL(specifier, {
  from: importer,
  try: true,
  conditions: ['node', 'import', 'production'],
})
// Emits DEP0155 and returns undefined.

Here:

  • lookupNodeModuleSubpath is from mlly.
  • join is from pathe, as used by Nitro.
  • resolveModuleURL is from exsolve.
  • importer is the file URL of Nuxt's installed error-500.mjs template.

As a control, resolving @vue/shared with the same resolver options succeeds without the warning.

Describe the bug

During the Nitro server build, the node-externals plugin constructs the package specifier @vue/shared/ while trying to infer an importable package subpath. Passing this specifier to exsolve triggers a DEP0155 deprecation warning.

The original import in @nuxt/nitro-server/dist/runtime/templates/error-500.mjs does not contain a trailing slash:

import { escapeHtml } from '@vue/shared'

The observed resolution sequence is:

  1. mlly.lookupNodeModuleSubpath() returns "./" for the package root export.
  2. Nitro joins the package name with this subpath.
  3. join('@vue/shared', './') produces @vue/shared/.
  4. Nitro passes that specifier to exsolve.resolveModuleURL().
  5. exsolve emits DEP0155 while resolving the resulting "./" package subpath.

The actual build stack points to this statement in nitropack/dist/rollup/index.mjs:

const resolvedGuess =
  guessedSubpath && tryResolve(join(pkgName, guessedSubpath), importer)

Expected behavior

When the inferred subpath represents the package root, Nitro should resolve the bare package name, such as @vue/shared, without introducing a trailing slash.

Actual behavior

Nitro attempts to resolve @vue/shared/, producing the deprecation warning.

Additional context

The installed @vue/shared/package.json contains export keys "." and "./*". It does not contain a separate "./" export key.

Directly importing the Nuxt error-page template with Node.js and --trace-deprecation succeeds without emitting this warning.

Although mlly returns the "./" subpath, the warning in the actual build is emitted by exsolve, called from Nitro's node-externals plugin.

Logs

Local absolute paths have been shortened for readability.


[DEP0155] DeprecationWarning: Use of deprecated trailing slash pattern mapping "./"
in the "exports" field module resolution of the package at
<project>/node_modules/.pnpm/@[email protected]_<hash>/node_modules/@vue/shared/package.json
imported from
<project>/node_modules/.pnpm/@[email protected]_<hash>/node_modules/@nuxt/nitro-server/dist/runtime/templates/error-500.mjs.
Mapping specifiers ending in "/" is no longer supported.

    at emitTrailingSlashPatternDeprecation (exsolve/dist/index.mjs:650:12)
    at packageExportsResolve (exsolve/dist/index.mjs:669:38)
    at packageResolve (exsolve/dist/index.mjs:771:82)
    at moduleResolve (exsolve/dist/index.mjs:809:14)
    at _tryModuleResolve (exsolve/dist/index.mjs:915:10)
    at resolveModuleURL (exsolve/dist/index.mjs:866:16)
    at tryResolve (nitropack/dist/rollup/index.mjs:346:17)
    at Object.resolveId (nitropack/dist/rollup/index.mjs:417:51)
    at async PluginDriver.hookFirstAndGetPlugin (rollup/dist/es/shared/node-entry.js:22743:28)
    at async resolveId (rollup/dist/es/shared/node-entry.js:21205:26)


Isolated reproduction output:


subpath: "./"
specifier: "@vue/shared/"

Resolving: @vue/shared
file:///<project>/node_modules/.pnpm/@[email protected]/node_modules/@vue/shared/dist/shared.cjs.prod.js

Resolving: @vue/shared/
undefined

[DEP0155] DeprecationWarning: Use of deprecated trailing slash pattern mapping "./" ...

Activity

  1. added
    pending triage
    on Sep 11, 2026
  2. nikolas-sapa commented on Sep 13, 2026

    @nikolas-sapa

    Confirmed on v2 (nitropack 2.13.4), and your trace is exactly right. Since the report is missing the minimal reproduction the PR template asks for, here is a self-contained one that needs no Nuxt and no network.

    Minimal reproduction

    The trigger needs two things in the dependency's exports map: a root export that resolves to a different file than the one rollup hands Nitro (which is what pushes resolution into the "guess the subpath" branch), and a wildcard key (which is what makes a trailing-slash subpath match a deprecated pattern). @vue/shared has both.

    mkdir repro && cd repro
    echo '{"name":"repro","type":"module"}' > package.json
    npm i mlly pathe exsolve          # install first: npm prunes extraneous packages
    touch importer.mjs
    
    mkdir -p node_modules/@scope/pkg/dist
    cat > node_modules/@scope/pkg/package.json <<'EOF'
    {
      "name": "@scope/pkg",
      "version": "1.0.0",
      "type": "module",
      "exports": {
        ".": {
          "node": { "production": "./dist/index.prod.js", "default": "./dist/index.js" },
          "default": "./dist/index.js"
        },
        "./*": "./*"
      }
    }
    EOF
    echo 'export const a = 1;' | tee node_modules/@scope/pkg/dist/index.js > node_modules/@scope/pkg/dist/index.prod.js
    // repro.mjs
    import { lookupNodeModuleSubpath } from "mlly";
    import { join } from "pathe";
    import { resolveModuleURL } from "exsolve";
    import { fileURLToPath } from "node:url";
    
    const pkgName = "@scope/pkg";
    const opts = {
      try: true,
      conditions: ["node", "import", "production"],
      from: [new URL("importer.mjs", import.meta.url)],
      suffixes: ["", "/index"],
      extensions: [".mjs", ".cjs", ".js", ".mts", ".cts", ".ts", ".json"],
    };
    
    const id = fileURLToPath(
      new URL("node_modules/@scope/pkg/dist/index.js", import.meta.url)
    );
    
    const guessedSubpath = await lookupNodeModuleSubpath(id);
    console.log("guessedSubpath:", JSON.stringify(guessedSubpath));
    console.log("joined        :", JSON.stringify(join(pkgName, guessedSubpath)));
    console.log("resolves to   :", resolveModuleURL(join(pkgName, guessedSubpath), opts));
    $ node --trace-deprecation repro.mjs
    guessedSubpath: "./"
    joined        : "@scope/pkg/"
    resolves to   : undefined
    
    (node:15722) [DEP0155] DeprecationWarning: Use of deprecated trailing slash pattern
    mapping "./" in the "exports" field module resolution of the package at .../package.json
        at emitTrailingSlashPatternDeprecation (exsolve/dist/index.mjs:650:12)
        at packageExportsResolve (exsolve/dist/index.mjs:669:38)
        at packageResolve (exsolve/dist/index.mjs:771:82)
        at moduleResolve (exsolve/dist/index.mjs:809:14)
        at _tryModuleResolve (exsolve/dist/index.mjs:915:10)
        at resolveModuleURL (exsolve/dist/index.mjs:866:16)
    

    Same frames as your build trace.

    Where the "./" comes from

    It is not an accident of the package — it is how mlly denotes the package root. lookupNodeModuleSubpath falls through to _flattenExports, which builds each entry's subpath with joinURL(parentSubpath, subpath) starting from "./". For the "." key that is joinURL("./", "") → "./". So every package root export reverse-maps to "./", and join(pkgName, "./") keeps the slash.

    Then in exsolve, packageExportsResolve emits DEP0155 whenever the requested subpath ends in / and matches a wildcard key (index.mjs:669) — hence the "./*" requirement above.

    One consequence not mentioned in the report

    The warning is the visible symptom, but resolveModuleURL also returns undefined for the trailing-slash specifier. In externals.ts#L157-L167 that means resolvedGuess !== id, so resolveId falls through to return null — the dependency is inlined into the server bundle instead of being externalized. For @vue/shared that is small, but it applies to any dependency whose root export resolves differently under Nitro's conditions than under rollup's.

    Fix

    withoutTrailingSlash() (already used elsewhere in src/) turns "./" into ".", and join(pkgName, ".") is exactly pkgName:

    -          const resolvedGuess =
    -            guessedSubpath &&
    -            tryResolve(join(pkgName, guessedSubpath), importer);
    +          const guessedId = guessedSubpath
    +            ? join(pkgName, withoutTrailingSlash(guessedSubpath))
    +            : undefined;
    +          const resolvedGuess = guessedId && tryResolve(guessedId, importer);
               if (resolvedGuess === id) {
                 trackedExternals.add(resolvedGuess);
                 return {
    -              id: join(pkgName, guessedSubpath!),
    +              id: guessedId!,
                   external: true,
                 };
               }

    Every other subpath shape is unchanged ("./dist/x.js" → "pkg/dist/x.js"). And because the guess is only used when it resolves back to id, normalizing the specifier cannot introduce an incorrect external — a wrong guess still fails the equality check and falls through to inlining exactly as before.

    I have this on a branch with a regression test that asserts no DEP0155 is emitted (it fails without the fix with the message above). Full suite is green locally: unit + node, nitro-dev, aws-lambda, azure, netlify, netlify-legacy, vercel, static presets. Happy to open the PR against v2 if you'd like it.

  3. lvzhenbo commented on Oct 4, 2026

    @lvzhenbo
    Author

    H3 V2 stable release is out; we can now look forward to the stable releases of Nitro V3 and Nuxt V5. Since no one has come forward to resolve this issue, it’s no longer important.

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

    pending triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions