Shouldn’t you use path.sep instead of '\\'?
path.sep
'\\'
const parts = path.relative('.', filePath).split(path.sep);