fix(cli): Init nodes dir to ensure npm install succeeds (#3934)

Init nodes folder when created so npm doesnt fail
This commit is contained in:
Omar Ajoue 2022-08-24 11:58:47 +02:00 committed by GitHub
parent db02a379d9
commit 2d6eea82d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: {
@ -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);