diff --git a/packages/nitro/src/rollup/plugins/externals.ts b/packages/nitro/src/rollup/plugins/externals.ts index 627ce7ae13..20cd72adf3 100644 --- a/packages/nitro/src/rollup/plugins/externals.ts +++ b/packages/nitro/src/rollup/plugins/externals.ts @@ -75,7 +75,7 @@ export function externals (opts: NodeExternalsOptions): Plugin { const pkgs = new Set() for (const file of tracedFiles) { // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [_, baseDir, pkgName, _importPath] = /(.+\/node_modules\/)([^@/]+|@[^/]+\/[^/]+)\/(.*)/.exec(file) + const [_, baseDir, pkgName, _importPath] = /^(.+\/node_modules\/)([^@/]+|@[^/]+\/[^/]+)(\/?.*?)?$/.exec(file) pkgs.add(resolve(baseDir, pkgName, 'package.json')) }