Skip to content

Commit

Permalink
fix(cli): Init nodes dir to ensure npm install succeeds (#3934)
Browse files Browse the repository at this point in the history
Init nodes folder when created so npm doesnt fail
  • Loading branch information
krynble authored Aug 24, 2022
1 parent db02a37 commit 2d6eea8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/cli/src/CommunityNodes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ export const executeCommand = async (
): Promise<string> => {
const downloadFolder = UserSettings.getUserN8nFolderDowloadedNodesPath();

try {
await fsAccess(downloadFolder);
} catch (_) {
await fsMkdir(downloadFolder);
}

const execOptions = {
cwd: downloadFolder,
env: {
Expand All @@ -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);

Expand Down

0 comments on commit 2d6eea8

Please sign in to comment.