Intro to NPM

benjaminklein99

Benjamin Klein

Posted on April 17, 2023

Intro to NPM

NPM is a free to use software registry. It's also the worlds largest software registry, containing over 800,000 code packages. NPM make a software engineers life easier by making it possible to quickly download code that someone else has written, or upload code for you, or possibly someone else, to use later on. Want to learn how to implement NPM into your workflow? Just keep reading!

How to install NPM

To get started with NPM, you first have to install it. NPM is installed with Node.js. If you don't already have Node.js installed you can install it from the official Node.js website: https://nodejs.org. If you are unsure or can't remember if you have previously installed Node.js, you can type node -v into the command line to check.

Now that we've got Node.js sorted out, we can download NPM! To download NPM, we can jump back into our command line and type: npm install -g npm. To make certain that NPM was installed properly we can enter npm -v into the command line, which will show what version of NPM is installed. Now we're all set to start using npm!

Package install

Installing a package from NPM is as simple as it gets. To download and install software, simply run the following command in the terminal with package replaced with your intended package.

// Windows Users:
C:\>npm install <package>

// Mac Users:
>npm install <package>
Enter fullscreen mode Exit fullscreen mode

How to upload using NPM

Say you're working on a company project and you would like to share a series of function to make this project and projects like it easier. You could just copy and paste your code into a messaging app and send it to them that way, but what happens when another project comes up that could use the same code? It would be a pain finding out who still has access to the code and who still needs it, on top of having to send the code to each person individually. Here's where NPM becomes useful. You can simply upload your code to NPM, that way anyone who needs it can access it at any time.

To upload a package to NPM, you first have to create an account. You can sign up here at their official website: https://www.npmjs.com/. Next you need to sign in using the terminal command: NPM login. Once you've hit enter, an input field should come up that looks something like this:

// Windows users:
C:\>npm login
Username: <your username>
Password: <your password>

// Mac Users:
>npm login
Username: <your username>
Password: <your password>
Enter fullscreen mode Exit fullscreen mode

Once you're logged in, navigate to your project that you would like to upload. Once you're in the desired directory, you can simply run the command: npm publish.
Now, you've officially upload a package to NPM!

NPM is a powerful tool that makes accessing code easy and simple. There are already plenty of packages uploaded to NPM that I guarantee can make your code more stream-lined, as well as make your life a bit easier. Here's a list of popular NPM Packages to checkout. Happy coding!

Work Cited:
https://www.w3schools.com/whatis/whatis_npm.asp
https://careerfoundry.com/en/blog/web-development/what-is-npm/#:~:text=npm%20stands%20for%20Node%20Package,over%2011%20million%20developers%20worldwide.
Image description

💖 💪 🙅 🚩
benjaminklein99
Benjamin Klein

Posted on April 17, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024

Modern C++ for LeetCode 🧑‍💻🚀
leetcode Modern C++ for LeetCode 🧑‍💻🚀

November 29, 2024