2

I'm working on a vue-cli/webpack project, and so far I've been adding packages with the following command:

yarn add <package> --dev

It saves them in the package.json file under the devDependencies. Everything works fine, but my build time is ~1 min. (yarn build)

I'm wondering if it is the proper way? I've seen some suggestions where people are adding them npm i <package> --save, or simply npm i <package>.

tk421
  • 5,775
  • 6
  • 23
  • 34
ierdna
  • 5,753
  • 7
  • 50
  • 84

1 Answers1

4

yarn and npm are just two different package managers that have the same purpose. Internally they might have different approaches but practically they do the same thing, managing your packages.

To answer your question there is no right way of installing packages, its more a matter of personal preference. npm i and yarn add will install your desired package inside the node_modules folder and thus will be available to your app. Actually you must use it inside your code (require/import) otherwise it will not end up in your bundle and your bundle size/time will not change.

The options --save-dev/-add are optional (but recommended) for persisting your new dependencies inside your package.json. If someone uses a fresh clone of your project he can run npm i or yarn to automatically install all dependencies from your package.json

truefalse10
  • 336
  • 1
  • 3