Run yarn in a different path

Yarnpkg

Yarnpkg Problem Overview


Is there a way to specify a working directory for yarn? This would be different then the --modules-folder option. Specifically, I'm trying to run the yarn install command from a location outside of the package location.

Similar to -C in git

Yarnpkg Solutions


Solution 1 - Yarnpkg

You can use --cwd like so yarn --cwd <path> <yarn command>.
The order of arguments is important.

Example:

yarn --cwd ~/test_project/ dev

Because the following will not work:

yarn dev --cwd ~/test_project/

Solution 2 - Yarnpkg

--cwd is what you want.

(tested with yarn 1.3.2)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmrbnetworksView Question on Stackoverflow
Solution 1 - YarnpkgmadavView Answer on Stackoverflow
Solution 2 - YarnpkgTim GreenView Answer on Stackoverflow