Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn - install modules in a specific directory

Tags:

yarnpkg

When I do $ yarn install, I see that ./node_modules directory gets created and modules are installed in that directory.

I also get that --modules-folder ./directory_location exists, to install in a specific directory one time.

Is there an option to always use a specific directory to install in package.json configuration?

like image 462
Jason Kim Avatar asked Jan 28 '17 16:01

Jason Kim


People also ask

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: ~/.

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 .

How do I install a specific yarn package?

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 ).

Where does yarn install dependencies?

To install dependencies, you have to run yarn install in the root of your directory to install all the dependencies for a project. The dependencies will be retrieved from the package. json file you pushed to version control, and will be stored in the yarn. lock file.


1 Answers

I am now using scripts to do this.

And I can run yarn run newinstall

In package.json

{
    ...
    "scripts": {
        "newinstall": "yarn install --modules-folder ./directory_location"
    }
    ...
}
like image 67
Jason Kim Avatar answered Sep 24 '22 14:09

Jason Kim