Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there's a command for yarn to install a subfolder?

Background:

We are using yarn in this project and we don't want to write our package.json scripts with a mix of npm/yarn commands.

I have a root directory which contains a few subfolders.

Each holds a different service.

I want to create a script in the root folder that npm install each of the services, one by one.

Question:

Do you know what would be the yarn alternative to npm install <folder>?

I'm looking for something like this psuedo command: yarn <folder>

like image 354
ueeieiie Avatar asked Feb 21 '18 14:02

ueeieiie


People also ask

How do I install a specific package with yarn?

You can specify versions using one of these: yarn add package-name installs the “latest” version of the package. yarn add [email protected] installs a specific version of a package from the registry. yarn add package-name@tag installs a specific “tag” (e.g. beta , next , or latest ).

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 does yarn install modules?

yarn will ensure all global packages will have their executables installed to ~/. yarn/bin . yarn global dir will print the output of the global installation folder that houses the global node_modules . By default that will be: ~/.


2 Answers

You could use --cwd there is a git issue about this :

yarn --cwd "your/path" script

You can also use cd :

cd "your/path" && yarn script
like image 129
ibenjelloun Avatar answered Sep 19 '22 05:09

ibenjelloun


To run multiple commands in a single subfolder:

cd your/path && yarn && yarn some-script
like image 30
Fellow Stranger Avatar answered Sep 21 '22 05:09

Fellow Stranger