>> Hi. I'm Burke Holland.
>> I'm Elijah Manor.
>> We're here in historic downtown Franklin,
Tennessee at the lovely Gray's on Main,
and we're here to bring you five things about npm.
Thing number one, you can run npm init
and then answer a billion questions.
>> Wait. There's a special flag for like,
if you do "npm init -y",
it will take all the defaults
and just make the package.json for you.
>> So you don't have to answer the billion questions?
>> No.
>> So you're saying npm -y and
then I don't have to answer all those questions.
>> I just saved you a lot of time.
>> Wow! That's like half my life back.
>> You're welcome.
>> You can fix npm install.
That's all of my life back.
>> That still going to take some time.
>> Little more complicated. Thing number 2,
sometimes you lose track of
all of the npm scripts that you have like start,
debug, start browsers, start server, debug browser.
There can be a lot across a lot of different projects.
What can we do to help with that?
>> One simple thing I do when I go to a new project,
especially if I'm not familiar with it,
I'll just type "npmRun",
"Enter", and it'll just
spit out all the available scripts.
>> Really? So just run without a script name,
just spits out all of the scripts that you can run.
>> Yep.
>> That's a very handy tip.
>> In npm, there's also
completion scripts that you can install.
In that we can do npmRun.
You can start typing and press "Tab",
and it will actually list out
all the matching hits that you could use.
>> Nice, and that's in the terminal.
>> Yep.
>> Thing number 3, there's something new out called npx,
and actually comes with npm.
What is npx and what does it do?
>> It's a great question.
So, if you at least have npm
5.2 or above, you already have it.
>> Okay.
>> It does two main things.
One, if you already have packages installed locally like,
for example eslint, you can actually play
around with it in the terminal
instead of being npm scripts.
So, if you run npx eslint parameters or whatever,
it will first look locally if it's installed,
and if you do have it it will use that one instead.
>> Oh! Okay. So you could have it installed locally but
use it like it's installed globally. Does that work?
>> Yeah.
>> Well, what happens if I try to use it and it's
not installed locally or globally?
>> Well, that's good. So that's
the second thing that it could do.
So, if you don't have it
locally or globally it will actually
go install it temporarily just so you can use it,
and then it just gets rid of it.
>> Okay. So without work for something like saying npx
Create React App and
then the name without having to install.
>> Yeah. That's a great reason
to use it because it's always
getting the latest version and Create
React App so you're not out of date.
>> Wow! That's fine. Cause it's so
easy for you to get out of date if you intall globally?
>> Right, yeah.
>> So, that's npx available with npm 5.2 or above.
If you've got that, you can use that today.
>> Yeah.
>> Thing number 4, you can use
npm to update your packages,
but a lot of times it's not that simple.
What are some things that we can do to make
a package updating a little bit less painful?
>> It's a great question.
So, the first step would maybe
running something that's native with npm,
and you would say "npm outdated",
and that's a tool that will just
run through your package.json,
looking to see if there's
newer versions of things based on your version range,
and but it's just a read only.
>> That's a good tip. I didn't know about that one.
>> Yeah.
>> But, you didn't do anything,
it's just a list of what's okay. So?
>> At that point you'd have to
manually install it yourself
or there's another tool that I like
to use, it's called npm-check.
>> That's the name of the package, so on npm, npm-check.
>> You would install that either globally or use npx,
and then you use the "-u" flag
and that will do the same thing,
it'll figure out what's up to date, out of date.
It'll give you a list, but then is it interactive.
You can actually use the keyboard to
select things and tell it
I want these certain ones to be upgraded right now.
>> Wow! That's fancy schmancy.
Also, there's an extension for
visual studio code called Version Lens
that replaces information inside your
package.json file that also lets you update.
So, you can check that out as well.
>> Yeah. That's a good one.
>> Number 5, it's possible to link npm packages.
When we do this in development to
define dependencies between packages,
it's great, but if you link a lot of
packages it can get really hard to manage.
Is there anything that we can do to make that easier?
>> That's a great question.
I do this all the time at work.
We're always developing
multiple slices and packages together.
For me, I always forget it
like what do I currently have linked,
am I running the latest or local version and there's
a nice npm tool called "link-status" and all it does is.
>> So you can install that from npm,
link-status is the name of the package?
>> Either globally or use npx,
and it will just, based on the project you're in,
it'll just list out all your links dependencies and
there's a pretty mode so it looks pretty,
but I mean that's all it does,
but I use it all the time.
>> Yeah. It's really powerful because
otherwise you just don't know,
you find it completely blinding.
Excellent. I'm Burke Holland.
>> and I'm Elijah Manor.
>> and now you know five things about npm.
>> Yes!