tests: Pass --legacy-peer-deps flag to work around npm v7 bug

This flag is unknown to npm v6, but npm v6 silently ignores unknown
flags.
This commit is contained in:
Richard Hansen 2021-02-15 19:10:55 -05:00
parent 588b73f366
commit 6198e92706
9 changed files with 28 additions and 12 deletions

View file

@ -32,7 +32,9 @@ exports.uninstall = async (pluginName, cb = null) => {
logger.info(`Uninstalling plugin ${pluginName}...`);
try {
// The --no-save flag prevents npm from creating package.json or package-lock.json.
await runCmd(['npm', 'uninstall', '--no-save', pluginName]);
// The --legacy-peer-deps flag is required to work around a bug in npm v7:
// https://github.com/npm/cli/issues/2199
await runCmd(['npm', 'uninstall', '--no-save', '--legacy-peer-deps', pluginName]);
} catch (err) {
logger.error(`Failed to uninstall plugin ${pluginName}`);
cb(err || new Error(err));
@ -49,7 +51,9 @@ exports.install = async (pluginName, cb = null) => {
logger.info(`Installing plugin ${pluginName}...`);
try {
// The --no-save flag prevents npm from creating package.json or package-lock.json.
await runCmd(['npm', 'install', '--no-save', pluginName]);
// The --legacy-peer-deps flag is required to work around a bug in npm v7:
// https://github.com/npm/cli/issues/2199
await runCmd(['npm', 'install', '--no-save', '--legacy-peer-deps', pluginName]);
} catch (err) {
logger.error(`Failed to install plugin ${pluginName}`);
cb(err || new Error(err));