How to change Yarn default packages directory?

Mladen Janjetovic picture Mladen Janjetovic · Nov 8, 2016 · Viewed 25.3k times · Source

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"

Answer

user2977243 picture user2977243 · Dec 9, 2016
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.