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

CLI doesn't use yarn to install package? #1115

Open
vegawong opened this issue Apr 2, 2021 · 8 comments
Open

CLI doesn't use yarn to install package? #1115

vegawong opened this issue Apr 2, 2021 · 8 comments

Comments

@vegawong
Copy link

vegawong commented Apr 2, 2021

image

My project has the yarn.lock file but not package-lock.json. Should it auto use yarn to install package?

I saw the source at

if (files.findIndex((filename) => filename === 'yarn.lock') > -1) {
.

@jmcdo29
Copy link
Member

jmcdo29 commented Apr 2, 2021

Can you provide reproduction steps for this?

@vegawong
Copy link
Author

vegawong commented Apr 2, 2021

@jmcdo29 https://codesandbox.io/s/smoosh-snow-j0yvf
In codesanbox, create a teminal and type input yarn exec nest g res user modules

@jmcdo29
Copy link
Member

jmcdo29 commented Apr 2, 2021

@kamilmysliwiec it looks like the schematics generator doesn't take into account the package manager. I'm trying to look into where that can be added. Let me know if you know where off the top of your head

@kamilmysliwiec
Copy link
Member

https://github.com/nestjs/schematics/blob/master/src/lib/resource/resource.factory.ts#L180-L186

The NodePackageInstallTask function takes an options object as a parameter. @jmcdo29 one of the available configuration properties is the packageManager which we could use to determine what package manager should be used (I'm not sure what managers are supported though, but Yarn is certainly one of them). Now, to decide what package manager is being used by the project, we could check whether package-lock.json or yarn.lock file is present in the root directory.

@vegawong
Copy link
Author

vegawong commented Apr 4, 2021

How can i use yarn? Any cli option support or config support?

@jmcdo29
Copy link
Member

jmcdo29 commented Apr 4, 2021

We'll need to make an update to the schematics that Kamil pointed out. You're welcome to make a PR or wait for one of us to have the time to do it

@RileyMShea
Copy link

RileyMShea commented Jul 15, 2021

In lieu of deprecating yarn support entirely, I'd like to advocate that yarn be presented as yarn (experimental) when given the option to choose a package manager with nest new. There are simply too many breaking issues with yarn and nestjs, presenting yarn and npm to the user as equally supported options is setting them up for a bad time. They're going to find out the yarn support isn't there eventually, so might as well be upfront with them about it.

@kamilmysliwiec
Copy link
Member

yarn works totally fine with Nest CLI and there's no reason to flag it as experimental (especially after 3-4 years when all yarn users have been successfully using it with Nest). This issue is mainly about the new resource schematic that we added a few months ago and the "packages installation" part is actually just a minor thing that shouldn't have any impact on the application itself.

Let me lock this issue to prevent future off-topic. We'll look into this issue as soon as we can.

@nestjs nestjs locked and limited conversation to collaborators Jul 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants