DEV Community

Discussion on: Setup a Monorepo with PNPM workspaces and speed it up with Nx!

Collapse
 
damian_cyrus profile image
Damian Cyrus

This was a nice read, and I definetly try it out in deep in the next days.

One think is irritating: Why do you use npx when you used pnpm? (I see that more and more in posts related to pnpm)

There are two other options how you can run this with pnpm:

They are different, but both should work fine. As nx is installed locally you can run it with pnpm exec nx .... All of the mentioned npx commands work fine with this.

Collapse
 
jtlapp profile image
Joe Lapp

To run tasks in dependency order. For example, pnpm does not know which workspaces have to be built before other workspaces. Order can matter when one workspace depends on the outputs generated by another, such as .d.ts files, web bundles, or generated schema interfaces.

Collapse
 
damian_cyrus profile image
Damian Cyrus

I meant commands like: npx nx affected:<target>

Could be: pnpm exec nx affected:<target>

Running that should give you the same result, and nx is doing all the other parts, right? I don't see why in these cases two package managers should be used. Maybe I missed something?

You are right on the dependency order with pnpm, but isn't that nx job?

Thread Thread
 
jtlapp profile image
Joe Lapp

Oh, sorry. I read that as "why use nx rather than pnpm?" I too find it easier to type npx rather than pnpm exec.