Search code examples
javascriptnpmgulpboweryarnpkg

How do I only put dependencies into a specific folder for yarn?


Background

I have been using bower for handling dependencies, however now I would like to migrate to yarn. The main hurdle I am having is migrating from the below .bowerc file to .yarnrc.

.bowerrc

{
     "directory": "src/vendors"
}

The issue is I could make a .yarnrc file, like below that will put any dependency into src/vendors, but that includes devDependencies.

.yarnrc

--modules-folder src/vendors

Question

How do I only put dependencies into src/vendors and putdevDependencies in node_modules?


Solution

  • You could use --production option to tell yarn which dependencies you want to install; if set to true it will just install dependencies.

    So in your src folder make a .yarnrc file with the following content:

    --modules-folder vendors
    --production true
    

    and in your project dir, in .yarnrc file, set --production to false:

    --production false
    

    folder structure:

    .
    ├── package.json
    ├── src
    │   └── .yarnrc
    └── .yarnrc