Search code examples
javascriptnpmyarnpkg

Install package only for one project


Let's say I have this file hierarchy:

packages/project1
packages/project2

and the workspace is packages/*

How do I install an npm package only for project1 and not for project2 (without using just "npm install" inside the packages/project1 directory because I need the yarn lock file to include the dependency)?

Does yarn support this functionality? Couldn't find it in the docs.


Solution

  • yarn add <package...> [--dev/-D]
    

    Using --dev or -D will install one or more packages in your devDependencies. See here