Search code examples
npmyarnpkg

What does the command `npm i -S packagename` do and what is the yarn equivalent to this npm command?


What does -S stand for in an npm command? And where the added package is added in package.json? in "devDependencies" or in "dependencies" collection?

I have seen other questions like the ones below, but none of them covers the yarn equivalence for that:

What is the equivalent of "npm install <package_name> --save" in Yarn?

What does the npm -S flag mean?


Solution

  • See npm install --help (or https://docs.npmjs.com/cli/v9/using-npm/config): -S means --save which has been true by default since like forever, and is documented as:

    Save installed packages to a package.json file as dependencies.

    Contrary to --save-dev:

    Default: false

    Save installed packages to a package.json file as devDependencies.