From f10f5a117ce3a303dc8626b9689c52e8873651a2 Mon Sep 17 00:00:00 2001 From: magnus Date: Tue, 6 Jan 2026 20:07:49 +0100 Subject: [PATCH 1/2] fix(installDeps): Ensure symlinks are dereferenced on all Node versions --- .changeset/fifty-kiwis-begin.md | 7 ++++ packages/open-next/src/build/installDeps.ts | 41 ++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 .changeset/fifty-kiwis-begin.md diff --git a/.changeset/fifty-kiwis-begin.md b/.changeset/fifty-kiwis-begin.md new file mode 100644 index 000000000..656d61502 --- /dev/null +++ b/.changeset/fifty-kiwis-begin.md @@ -0,0 +1,7 @@ +--- +"@opennextjs/aws": patch +--- + +fix(installDeps): Ensure symlinks are dereferenced on all Node versions + +Upstream issue in Node: https://github.com/nodejs/node/issues/59168 \ No newline at end of file diff --git a/packages/open-next/src/build/installDeps.ts b/packages/open-next/src/build/installDeps.ts index 752fb937c..5b8e63e02 100644 --- a/packages/open-next/src/build/installDeps.ts +++ b/packages/open-next/src/build/installDeps.ts @@ -7,8 +7,6 @@ import type { InstallOptions } from "types/open-next"; import logger from "../logger.js"; -const AFFECTED_NODE_VERSIONS = ["22.17.0", "22.17.1", "22.18.0"]; - export function installDependencies( outputDir: string, installOptions?: InstallOptions, @@ -54,34 +52,33 @@ export function installDependencies( { recursive: true, force: true, dereference: true }, ); - // This is a workaround for Node `22.17.0` and `22.17.1` // https://github.com/nodejs/node/issues/59168 - const nodeVersion = process.versions.node; - if (AFFECTED_NODE_VERSIONS.includes(nodeVersion)) { - const tempBinDir = path.join(tempInstallDir, "node_modules", ".bin"); - const outputBinDir = path.join(outputDir, "node_modules", ".bin"); - - for (const fileName of fs.readdirSync(tempBinDir)) { - const symlinkPath = path.join(tempBinDir, fileName); - const stat = fs.lstatSync(symlinkPath); + // This is a workaround for all Node versions. It seems to be an issue continue to affect new versions aswell. + // Therefor I think the most logical solution is to always run this workaround instead of trying to figure out which versions are affected. + const tempBinDir = path.join(tempInstallDir, "node_modules", ".bin"); + const outputBinDir = path.join(outputDir, "node_modules", ".bin"); - if (stat.isSymbolicLink()) { - const linkTarget = fs.readlinkSync(symlinkPath); - const realFilePath = path.resolve(tempBinDir, linkTarget); + for (const fileName of fs.readdirSync(tempBinDir)) { + const symlinkPath = path.join(tempBinDir, fileName); + const stat = fs.lstatSync(symlinkPath); - const outputFilePath = path.join(outputBinDir, fileName); + if (stat.isSymbolicLink()) { + const linkTarget = fs.readlinkSync(symlinkPath); + const realFilePath = path.resolve(tempBinDir, linkTarget); - if (fs.existsSync(outputFilePath)) { - fs.unlinkSync(outputFilePath); - } + const outputFilePath = path.join(outputBinDir, fileName); - fs.copyFileSync(realFilePath, outputFilePath); - fs.chmodSync(outputFilePath, "755"); - logger.debug(`Replaced symlink ${fileName} with actual file`); + if (fs.existsSync(outputFilePath)) { + fs.unlinkSync(outputFilePath); } + + fs.copyFileSync(realFilePath, outputFilePath); + fs.chmodSync(outputFilePath, "755"); + logger.debug(`Replaced symlink ${fileName} with actual file`); } } - + // End of Node Workaround + // Cleanup tempDir fs.rmSync(tempInstallDir, { recursive: true, force: true }); logger.info(`Dependencies installed for ${name}`); From 5a9038a85af3c0f6d26d77c5cf658826e181c0ee Mon Sep 17 00:00:00 2001 From: magnus Date: Tue, 6 Jan 2026 20:28:13 +0100 Subject: [PATCH 2/2] lint --- packages/open-next/src/build/installDeps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/open-next/src/build/installDeps.ts b/packages/open-next/src/build/installDeps.ts index 5b8e63e02..21237f4cc 100644 --- a/packages/open-next/src/build/installDeps.ts +++ b/packages/open-next/src/build/installDeps.ts @@ -78,7 +78,7 @@ export function installDependencies( } } // End of Node Workaround - + // Cleanup tempDir fs.rmSync(tempInstallDir, { recursive: true, force: true }); logger.info(`Dependencies installed for ${name}`);