Skip to content

Commit 774696c

Browse files
committed
fix: handle node_modules in standalone's dist dir
1 parent 1a8230b commit 774696c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/build/content/server.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,23 @@ export const copyNextServerCode = async (ctx: PluginContext): Promise<void> => {
146146
await cp(srcPath, destPath, { recursive: true, force: true })
147147
}),
148148
)
149+
150+
// this is different node_modules than one handled `copyNextDependencies`
151+
// this is under the standalone/.next folder (not standalone/node_modules)
152+
// and started to be created by Next.js in some cases in [email protected]
153+
if (existsSync(join(srcDir, 'node_modules'))) {
154+
const filter = ctx.constants.IS_LOCAL ? undefined : nodeModulesFilter
155+
const src = join(srcDir, 'node_modules')
156+
const dest = join(destDir, 'node_modules')
157+
await cp(src, dest, {
158+
recursive: true,
159+
verbatimSymlinks: true,
160+
force: true,
161+
filter,
162+
})
163+
164+
await recreateNodeModuleSymlinks(ctx.resolveFromSiteDir('node_modules'), dest)
165+
}
149166
})
150167
}
151168

0 commit comments

Comments
 (0)