Open vegawong opened 3 years ago
Can you provide reproduction steps for this?
@jmcdo29 https://codesandbox.io/s/smoosh-snow-j0yvf
In codesanbox, create a teminal and type input yarn exec nest g res user modules
@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
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.
How can i use yarn? Any cli option support or config support?
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
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.
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.
My project has the
yarn.lock
file but notpackage-lock.json
. Should it auto useyarn
to install package?I saw the source at https://github.com/nestjs/nest-cli/blob/8d8c1fdc5616b0d6d553dbc87ddaf38979c12187/lib/package-managers/package-manager.factory.ts#L25.