Persisting data(node_modules) between pipelines

I currently have a monorepo combine with yarn workspace and lerna. When changes are made to 1 app or 1 package, I will trigger different pipelines to test and build that only changed app/package.
Currently, if I run yarn, it will install dependencies for every apps and packages.
My question is:

  1. Is it possible to configure lerna or yarn to install dependencies for only that app/package?
  2. If not, then is it possible to persist node_modules from Install-Yarn-Pipeline to Test-Build-App/Package-Pipeline? (just like you persist to workspace in a workflow)

Here is a rough structure of the repo:

├── apps
      ├── apps_1
      ├── apps_2
      ├── apps_n
├── packages
      ├── packages_1
      ├── packages_2
      ├── packages_n
├── node_modules
├── lerna.json
└── yarn.lock

As far as I know,
if you are installing packages external to the monorepo, you can just cd into the package in question and yarn install inside of it.

run: |
  cd packages/package_1
  yarn install
1 Like