Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[preferred-pm] Reporting Yarn when inside an NPM workspace #180

Closed
erunion opened this issue Oct 18, 2023 · 1 comment · Fixed by #183
Closed

[preferred-pm] Reporting Yarn when inside an NPM workspace #180

erunion opened this issue Oct 18, 2023 · 1 comment · Fixed by #183

Comments

@erunion
Copy link

erunion commented Oct 18, 2023

If you run the following code snippet from inside of a workspace directory in an NPM package (like packages/<pkgname>), the call to findYarnWorkspaceRoot() in preferred-pm ends up thinking that we're using Yarn.

import preferredPM from 'preferred-pm';

preferredPM(process.cwd()).then(pm => console.log(pm));

I'm not exactly sure how to fix this because you can't easily know if you're in an NPM workspace without recursively parsing the parent directories until you find a package.json and see the workspaces key.

@erunion erunion changed the title preferred-pm reporting Yarn when inside an NPM workspace [preferred-pm] Reporting Yarn when inside an NPM workspace Oct 19, 2023
@wesleytodd
Copy link

wesleytodd commented Nov 14, 2023

I think the only correct answer here is to not check for the existence of the workspaces key as an indicator of yarn usage. I think what needs to happen is to find the "root" and then look for the lockfile there. Since yarn does not allow turning off lockfiles, you can assume that if there is no yarn.lock there but you have a workspaces key then it is an npm project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants