Search code examples
productionyarnpkg-v2

How to install only production dependencies in modern yarn when using node-modules linker


I'm using modern Yarn (v3.2.4 to be exact) which differs from Yarn Classic.

I'm using the nodeLinker: node-modules option in .yarnrc.yml so /node_modules are created, and dependencies are not saved to the repo.

I want to install only production dependencies (no devDependencies) but the --production flag isn't support in in Yarn 3. How can I do this?


Solution

  • As user Bobby mentioned in the other answer, it is possible to install only production dependencies by using the Yarn Workspace plugin.

    This requires that the plugn be installed first: yarn plugin import workspace-tools.

    Then install with: yarn workspaces focus --production.