NodeBB icon indicating copy to clipboard operation
NodeBB copied to clipboard

Use `packageManager` field in `package.json` for package manager detection

Open oplik0 opened this issue 2 years ago • 1 comments

Currently NodeBB uses either config.json or it falls back to basic lockfile detection. However, with the addition of corepack, package.json can now carry that information in packageManager field.

I think it would be reasonable to also respect that field, though I'm not sure if it should take precedence over lockfiles (I guess it should be below explicit NodeBB configuration though).

Additionally, I think the logic for selecting package manager from package.json and lockfiles could be expanded to work without nconf.

I can try doing both when I know the preferred priority of packageManager/lockfile check :)

oplik0 avatar Jun 18 '22 22:06 oplik0

Probably something like this:

  1. If packageManager defined in package.json, use that value
  2. Otherwise, check package_manager in config.json (legacy)
  3. Finally, use lockfile detection if all else fails (which then falls back to npm if the detection comes up empty)

That said, we wouldn't explicitly set packageManager in install/package.json. This would be something an admin would elect to add to their own package.json

julianlam avatar Jun 19 '22 02:06 julianlam