DEV Community

Discussion on: npm tips/tricks

Collapse
jjjjcccjjf profile image
endan • Edited on

I want to mention two things for beginners out there like me.

  • Use npm init -y to skip all the questions in npm init
  • Some NPM package documentations don't explicitly mention to use --save flag in their npm install quickstart or install guide. This had me confused at first. I wondered why won't they add a --save flag because if you upload your application it would break because of missing dependencies. The dev said it's up to you if you want to use their package as a dependency or a dev dependency. But obviously, the package they are offering should be saved as a core dependency (and so he modified the docs).

TLDR: Some documentation don't mention the --save or --save-dev flag in their installation. Don't be afraid to add either flags!

Collapse
markadell profile image
Mark Adel

Also npm version 5 saves the package in package.json by default, If you don’t want to save, you can override the default saving with --no-save

Collapse
nickytonline profile image
Nick Taylor (he/him) Author

I think like package-lock.json, this was another nice feature of yarn they implemented.

Collapse
jjjjcccjjf profile image
endan

Oh.. that's a neat addition. Last time I checked, it didn't save in my package.json. Maybe I have a lower version of npm. Thanks for this! Really useful!

Thread Thread
nickytonline profile image
Nick Taylor (he/him) Author

Maybe you were using an npm version lower than 5