Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run yarn in a different path

Tags:

yarnpkg

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

like image 990
mrbnetworks Avatar asked Oct 23 '17 14:10

mrbnetworks


People also ask

How do I change the directory of yarn?

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 .

Where do you run yarn commands?

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.

How do I change the environment variable in yarn?

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 .


1 Answers

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/ 
like image 145
madav Avatar answered Sep 19 '22 17:09

madav