If you ever installed an NPM package the following syntax looks very familiar to you:
npm install --save package_name
Enter fullscreen mo...
For further actions, you may consider blocking this person and/or reporting abuse
This has already been the case for 4 years, and npm has already had 2 more major versions since then. Handy info for people who didn't know, but why present it as if it's a new feature?
Some people aren’t aware of features, and it was a nice rundown of different commands. The author didn’t say it was a new feature, he specifically mentioned which NPM version came with the update.
I don't present it as a new feature?
That's why I mentioned it's been available since NPM 5, but a lot of people still default to typing --save in their installs scripts, so I thought it would be a good idea to make this public announcement again.
This is good info for me as there are tutorials out there in the wild that has the —save argument and I always wondered why it was needed. Now I know its no longer needed. Good to know.
Author probably didn't know about this until recently.
I do know about it, but I saw a lot of tutorials still mention the --save command, so wanted to make this publicly know ❤️
Exactly! People still mention the old way to save dependencies even nowadays
Even the install can be shortened to "i".
npm i
npm i -D (for dev dependencies)
uninstall can me shortened to
uni
It can also be shortened to just
npm un
Woo this is awesome cuz i can never spell uninstall properly
or
npm rm
,npm r
may be usefulYep! ❤️
Thanks for this! I wanted to write the same post because I still see people using
--save
everywhere even though it's the default.Now we just need to figure out how to raise the awareness further. :D
I think it will take some time, but we'll get there 🙏
use yarn instead
What reasons are there for using yarn instead, other than preference? Are there pros/cons of both? Yarn uses the NPM registry for packages, doesn’t it?
Yarn has emojis, therefore it's better 💁♀️
On a more serious note though, it's mostly personal preference, and I really love that I can just run
yarn
and will install my packages, and it's output is a lot cleaner and easier to read than what npm produces.I prefer yarn myself. Less verbose and more concise API in my opinion.
it caches packages, so it is fast
I think it's a personal preference, yarn did have some issues some years ago where their registry was down all the time, so decided to stick to NPM myself.
yes, absolutely
At least give some reasons why!
its fast, easy and easy to remember commands
How is it different (better?) to yarn and npm?
can some one please explain me difference between --save and --save-dev
Packages installed with —save-dev are only for development. In a production environment, they won’t be installed. You usually install things like linters, compilers, etc. as dev dependencies, since you don’t need them in production.
Thanks for explanation. so just for clarification i will -> npm i bootstrap@latest --save
Yeah. But
--save
is also the default, so you can leave it out.Thanks. hey we are going to change our frontend stack and SEO is main factor so what do you recommend Gatsby or NExt js (the backend is going to be php based ZEND framework's API's) and you can consider our website has blogs where content writers write blogs daily (we have builtin platform for that) also video viewing subscription based platform just like udemy so this is all we got on website so what do you recommend
I haven’t used Gatsby, so I can’t really compare the two.
Pawan, you should check out StackShare, it is a great resource for these types of architecture/stack comparisons unlike SO which mostly features on use-case specific solutions. 👍
stackshare.io
Thanks for this great explanation Andrew! 🙏
Just like npm.
--save-dev always confuses me, coming from python its generally the inverse. you add packages to your requirements.txt, then
pip install -r requirements.txt
orpip install -r requirements_dev.txt
have been doing
i -D
andi --save
. Never even tried a simplenpm i
. Never knew about that.I wish NPM can install production and development dependencies in one command, like this:
That would be awesome. I wonder if that’s been suggested on the npm cli GitHub repo. It might be worth checking if there’s already an issue for it.
The closest I can find is:
Detecting and installing Definitely Typed packages
I have literally never used --save flag. Pretty surprised to see this post.
This was needed before version 5 of NPM, so a lot of tutorials still have the save flag mentioned ❤️
Nice post!
In production build time, the optional packages how they will be handled?
Not a 100% sure on that actually.
Never found a good use-case for optional packages.
But then again build-time will probably only evaluate the "need" packages
Thanks!
Say goodbay to ‘npm install’, no need ‘npm install’, throw away ‘npm install’.