When using this (e.g. via ESLint extension in VSCode) in projects that have the following in their package.json file:
{
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": "11.4.0+sha512.f0febc7e37552ab485494a914241b338e0b3580b93d54ce31f00933015880863129038a1b4ae4e414a0ee63ac35bf21197e990172c4a68256450b5636310968f"
}
}
}
The installUsingNPM function in src/index.ts will fail to:
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid devEngines.packageManager
npm error EBADDEVENGINES Invalid name "pnpm" does not match "npm" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES current: { name: 'npm', version: '11.12.1' },
npm error EBADDEVENGINES required: {
npm error EBADDEVENGINES name: 'pnpm',
npm error EBADDEVENGINES version: '11.4.0+sha512.f0febc7e37552ab485494a914241b338e0b3580b93d54ce31f00933015880863129038a1b4ae4e414a0ee63ac35bf21197e990172c4a68256450b5636310968f'
npm error EBADDEVENGINES }
npm error EBADDEVENGINES }
Instead of hard-coding using npm, one could check whether process.env.npm_execpath exists, and use that instead. There are docs too.
When using this (e.g. via ESLint extension in VSCode) in projects that have the following in their
package.jsonfile:{ "devEngines": { "packageManager": { "name": "pnpm", "version": "11.4.0+sha512.f0febc7e37552ab485494a914241b338e0b3580b93d54ce31f00933015880863129038a1b4ae4e414a0ee63ac35bf21197e990172c4a68256450b5636310968f" } } }The
installUsingNPMfunction insrc/index.tswill fail to:Instead of hard-coding using
npm, one could check whetherprocess.env.npm_execpathexists, and use that instead. There are docs too.