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
The output directory can be changed by running yarn with the command line option --modules-folder . For example, if you wanted to install packages into a web/vendor directory instead of node_modules , you would add the modules-folder option on all yarn commands like yarn install --modules-folder web/vendor .
If you run yarn <script>[<args>] in your terminal, yarn will run a user-defined script. More on that in our tutorial on yarn run. When you run yarn <command> [<arg>] on the command line, it will run the command if it matches a locally installed CLI. So you don't have to setup user-defined scripts for simple use cases.
You can chain commands on the Windows command prompt with & (or && ). To set a environment variable you need to use the set command. The result should look like this: set PORT=1234 && yarn start:dev .
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With