Skip to content

Commit

Permalink
pnpm install: Disable strict-peer-dependencies and improve error mess…
Browse files Browse the repository at this point in the history
…aging. (#1191)
  • Loading branch information
raineorshine committed Sep 28, 2022
1 parent 21a9e29 commit 361dfe5
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/index.ts
Expand Up @@ -112,8 +112,34 @@ const npmInstall = async (
const packageManager = await getPackageManagerForInstall(options, pkgFile)
const cmd = packageManager + (process.platform === 'win32' ? '.cmd' : '')
const cwd = options.cwd || path.resolve(pkgFile, '..')
const stdout = await spawn(cmd, ['install'], { cwd })
print(options, stdout, 'verbose')
let stdout = ''
try {
await spawn(cmd, ['install'], {
cwd,
...(packageManager === 'pnpm'
? {
env: {
...process.env,
// With spawn, pnpm install will fail with ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies.
// When pnpm install is run directly from the terminal, this error does not occur.
// When pnpm install is run from a simple spawn script, this error does not occur.
// The issue only seems to be when pnpm install is executed from npm-check-updates, but it's not clear what configuration or environmental factors are causing this.
// For now, turn off strict-peer-dependencies on pnpm autoinstall.
// See: https://github.com/raineorshine/npm-check-updates/issues/1191
npm_config_strict_peer_dependencies: false,
},
}
: null),
stdout: (data: string) => {
stdout += data
},
})
print(options, stdout, 'verbose')
} catch (err: any) {
// sometimes packages print errors to stdout instead of stderr
// if there is nothing on stderr, reject with stdout
throw new Error(err?.message || err || stdout)
}
})
}
}
Expand Down

0 comments on commit 361dfe5

Please sign in to comment.