In this video, Emmanuel Henri introduces the base project that will be used throughout this course as the template.
- [Instructor] If you feel you have enough experience with NPM, and haven't taken the course where we explore the basics, here is a quick refresher of what we've explored in the previous course. So what we'll do is get back to our project and review some of the basic commands in NPM, while installing the packages we need inside of that project. So as you can see, we have a few projects that we need, or dependencies that we need to install in this project. We have socket.io, we have nodemon, express, and babel-cli, and so on, so forth.
So let's bring up the terminal inside of VS Code by clicking on View, Terminal, and the first command that you should be aware of is the npm install or you can do also the shorter version, npm i. So this will install all the dependencies listed here on the package.json file. Also, the other thing that we need to review is the uninstall. So we don't need socket.io in this project, so we'll uninstall this one, and the way to do that is by doing npm uninstall and sockio, and you'll see it disappear from the package.json file, as well.
So if we drop down our terminal, you'll see that it has disappeared from the dependencies. Perfect, now the other command that we've explored in the original course was how do you update dependencies? So there is an update command, but I would recommend against it. So I typically do npm install again a dependency. So if you see that express is already installed, and you want to update it to the latest version, you can do npm install and simply do express.
And you'll see that now we're at version 4 as opposed to 3. We could also play directly inside of the package.json file, delete all the node modules, like so, so right-click on node modules, Delete, Yes, and then, if you don't want nodemon installed, you can simply remove it from the list in the package.json file and then do an npm install, and then it will reinstall all the dependencies minus the nodemon.
But because we are using nodemon in our scripting, and this is something else that we need to review, this is the scripts that are part of this package.json file here. So if we want to actually use nodemon, which we are here, let's also make sure that we have nodemon, so I will reinstall nodemon and make sure that I save this. And nodemon reappears. One little caveat, if you are making changes directly in package.json and then do a command that will impact the package.json file, you want to make sure that you save it before because if I didn't save it before, it actually added back nodemon and wouldn't be able to do so.
So now we have nodemon and the last thing that we need to review again is the scripts. So this is something that we've explored in the previous course. As you can see, if we do npm start, it will run this script. If you run anything but a few command and you can take a look at the documentation to know which command that you can run without doing npm run, like start, there's another that's called init, you can use without doing run, for any other scripts that you create yourself, like nodemonthis, you need to do run before, so for example, we want to do nodemonthis, we need to do npm run nodemonthis, and then it will run this particular script here.
So this was an overview of everything that we've explored in the first course. So if you feel a little bit lost in what I just explained, please review the first course before you move on with this one.
- Publishing packages
- Updating a package
- Setting up tokens and authentication for private packages
- Working with scoped packages
- Running npm audits
- Troubleshooting npm