From 3516f40e060c0d63fb9bd03259042504361ef6e3 Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Mon, 9 Aug 2021 23:44:50 +0200 Subject: [PATCH] fix(nitro): fix EBUSY error on windows (#425) --- packages/nitro/src/rollup/plugins/externals.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/nitro/src/rollup/plugins/externals.ts b/packages/nitro/src/rollup/plugins/externals.ts index f52a318f1a..c83e51d7cb 100644 --- a/packages/nitro/src/rollup/plugins/externals.ts +++ b/packages/nitro/src/rollup/plugins/externals.ts @@ -81,12 +81,20 @@ export function externals (opts: NodeExternalsOptions): Plugin { } } - await Promise.all(tracedFiles.map(async (file) => { + const writeFile = async (file) => { const src = resolve(opts.traceOptions.base, file) const dst = resolve(opts.outDir, 'node_modules', file.split('node_modules/').pop()) await mkdirp(dirname(dst)) await copyFile(src, dst) - })) + } + if (process.platform === 'win32') { + // Workaround for EBUSY on windows (#424) + for (const file of tracedFiles) { + await writeFile(file) + } + } else { + await Promise.all(tracedFiles.map(writeFile)) + } } } }