turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Bug: when lockfile is not present turborepo can not identifier package manager in use

Open sambacha opened this issue 3 years ago • 2 comments

What version of Turborepo are you using?

latest

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Mac

Describe the Bug

when no lockfile present (yarn.lock or package-lock) turbo repo produces this error message:

 ERROR  could not determine package manager. Please set the "packageManager" property in your root package.json (https://nodejs.org/api/packages.html#packagemanager) or run `npx @turbo/codemod add-package-manager` in the root of your monorepo.

Expected Behavior

unsure on this, as I do not know how turborepo processes package manager distinctions

To Reproduce

However running the codemod isn't helpful: it needs a yarn.lock to proceed. This is occuring when you have installed a monorepo (yarn install) then remove lockfile (rm yarn.lock) then run npx turbo run build

sambacha avatar Mar 24 '22 20:03 sambacha

Confirmed. Sorry about that

jaredpalmer avatar Mar 24 '22 20:03 jaredpalmer

Oh. My. God.

I was struggling with this for SO long and I thought it was a "feature" to mandate the packageManager field in package.json!!

Would definitely love for a way for us to configure the package manager (in my case, I'm using npm) without packageManager or lockfiles.

My use case is that I'm developing a monorepo of libraries, and it's best practice to not have libraries include a lockfile on their own, so I've set the root level .npmrc with package-lock=false so that I wouldn't have to do that configuration across all of the packages.

I would really like to see this get addressed, as it is otherwise a blocker to adopting turbo. Thank you!

JaneJeon avatar Nov 08 '22 13:11 JaneJeon

Hey everybody, unfortunately I'm going to have to close this. It is actually not possible for us to infer which package manager to use without taking input from one of two locations: either the lockfile, or package manager inside of the monorepo root's package.json file.

In order for us to infer which package manager to use we must have some hint, and those are the only two concrete pieces of information we have available to us.

@JaneJeon It seems likely that you should set the packageManager property in the monorepo root's package.json. You'd get a lockfile in the root, but not in the libraries which would be individually published. That's how this repo is configured.

nathanhammond avatar Nov 09 '22 15:11 nathanhammond