diff --git a/src/util/fs.js b/src/util/fs.js index 15af11d0ba..0bd23c7cf5 100644 --- a/src/util/fs.js +++ b/src/util/fs.js @@ -644,7 +644,12 @@ export async function symlink(src: string, dest: string): Promise { await fsSymlink(src, dest, 'junction'); } else { // use relative paths otherwise which will be retained if the directory is moved - const relative = path.relative(fs.realpathSync(path.dirname(dest)), fs.realpathSync(src)); + let relative; + if (await exists(src)) { + relative = path.relative(fs.realpathSync(path.dirname(dest)), fs.realpathSync(src)); + } else { + relative = path.relative(path.dirname(dest), src); + } await fsSymlink(relative, dest); } } catch (err) {