Don't forget to set a section icon and cover page (if applicable)
For the copyright notice, make sure to:
Link to the MIT License of this course's GitHub repository. By default, the MIT License links to the Java course repo.
Update the copyright year
What is Npm?
Functions of Npm
There are lots of things, from downloading and using other’s packages, to sharing your own packages to the rest of the world, from making your (top secret projects) private and only shareable to people you choose (a.k.a for businesses), to managing multiple versions projects of code.
When it comes to the individual developer, there are lots of things you can do! The main things being
- Install && Manage dependencies:
- To install an npm package you would simple type (though this will change depending on the package, so make sure to consult their documentation):
- npm can install all the dependencies of a project / package (dependencies are any modules that are required by the npm package/project you install, to run: for example, in a random number generation game, the randomizer module is a dependency)
npm install <package>
- You can use it to share your own projects and packages to the world with the following steps:
- Sign up at https://www.npmjs.com
- Check if you are logged in with the
cmd: ‘npm whoami’command.
- If not, then log in first using the
cmd: ‘npm login’command
- After that, simply navigate to your project, using the command
cd <file path>and type into the terminal:
Alongside Npm comes a useful prepackaged tool called Npx, which is the second portion of this chapter.
What is Npx?
Npx is basically an Npm package runner that helps you install and run any sort of node based executable that you would normally install using Npm.
Functions of Npx
Npx is an extremely handy tool as it allows you to run dependencies and packages without installing them.
Here’s a quick overview of the advantages of this:
Usually, packages and dependencies are installed either locally, for that project alone, or globally, for all user projects. However, sometimes, people don’t want to install packages using either of those methods, or sometimes people might only want to experiment with new packages and not want to install them into a project (and if the package isn’t to their liking, uninstalling it).
This is where Npx shines. Instead of having to install those packages, Npx will simply run them without having to fully install it, thereby saving disk space, and allows you to experiment all you want.
Npx scripts change according to the package, so to use it you need to consult the package
Previous Section5.6 Writing Node with Frameworks
Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact firstname.lastname@example.org for inquiries.