Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Yarn default packages directory?

When Yarn is used to install dependencies, it puts them in node-modules directory by default.

How can I change this to i.e Laravel resources folder?
Like .bowerrc is used for bower to set "directory": "resources/assets"

like image 407
Mladen Janjetovic Avatar asked Nov 08 '16 13:11

Mladen Janjetovic


People also ask

How do I change the directory of my 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 packages?

yarn add file:/path/to/local/folder installs a package that is on your local file system.

Where is .yarnrc located?

Yarnrc files (named this way because they must be called . yarnrc. yml ) are the one place where you'll be able to configure Yarn's internal settings. While Yarn will automatically find them in the parent directories, they should usually be kept at the root of your project (often your repository).

What is .yarnrc file?

. yarnrc files allow you to configure additional Yarn features. The config command may also be used to set these options. Yarn will merge .


1 Answers

yarn install --modules-folder ./resources 

UPDATE: Keep an eye on this GitHub Issue as this feature is not quite stable.

UPDATE 2: From Damien's answer below, you can add --install.modules-folder "./resources" to a .yarnrc file so that you don't need to continually pass the commandline argument in for each subsequent invocation. Note that double quotes are required; without those, you will get an Invalid value type 1:25 or similar error.

You can then commit the .yarnrc to source control so that other developers on the project can use the same settings automatically.

like image 196
user2977243 Avatar answered Sep 26 '22 06:09

user2977243