From 2d6eea82d324d4560f7445d87647ce0d5e87c678 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Wed, 24 Aug 2022 11:58:47 +0200 Subject: [PATCH] fix(cli): Init nodes dir to ensure `npm install` succeeds (#3934) Init nodes folder when created so npm doesnt fail --- packages/cli/src/CommunityNodes/helpers.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/CommunityNodes/helpers.ts b/packages/cli/src/CommunityNodes/helpers.ts index 5fb30eb200..38544efdb5 100644 --- a/packages/cli/src/CommunityNodes/helpers.ts +++ b/packages/cli/src/CommunityNodes/helpers.ts @@ -78,12 +78,6 @@ export const executeCommand = async ( ): Promise => { const downloadFolder = UserSettings.getUserN8nFolderDowloadedNodesPath(); - try { - await fsAccess(downloadFolder); - } catch (_) { - await fsMkdir(downloadFolder); - } - const execOptions = { cwd: downloadFolder, env: { @@ -93,6 +87,15 @@ export const executeCommand = async ( }, }; + try { + await fsAccess(downloadFolder); + } catch (_) { + await fsMkdir(downloadFolder); + // Also init the folder since some versions + // of npm complain if the folder is empty + await execAsync('npm init -y', execOptions); + } + try { const commandResult = await execAsync(command, execOptions);