JavaScript first steps: Installing Node and reating an NPM project

avatar

node

I am a full-stack JavaScript developer. Using JS with Node is extremely easy and comfortable, although sometimes it can be too flexible.

I will start writing tutorials here to both share what I know, and to learn more from people's questions, but before that, I will show anyone interested how to start an NPM project.

I believe people here on Hive should be empowered with the power of coding, so I hope to start with the basics and eventually teach people how to create and maintain Hive apps. I want to create a new generation of creative and knowledgeable Hive devs. If you are a dev I invite you to help me.

The tutorials are supposed to be beginner-friendly, so I will try to go in-depth into the details, so forgive me for being slow, and you are welcome to ask questions.

Installing Node/NPM

Node is nothing more than your browser without the browser. It strips out the JavaScript engine from your browser to allow you to run it as a regular programming language interpreter.

To install it depends on your operating system.

For Windows and Mac, they have an installer and you can get it from:
https://nodejs.org/en/download/

If you need to install it on Linux it is going to depend on the distribution. They have a website listing all the distros:
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

But if you are using Debian/Ubuntu or any Debian/Ubuntu based distro you can just those commands on your console, each line at a time:

sudo apt update
sudo apt install nodejs
sudo apt install npm

If you are running BSD may god help you, cause I can't. I love BSD and its dedication to freedom but I have never used that operating system, although I may try it someday, so I won't be able to help. By quickly googling it you can find some tutorials for your BSD distro, I found this one for FreeBSD but since I never used the system I have no idea if it would work:
https://computingforgeeks.com/how-to-install-node-js-lts-npm-on-freebsd/

Creating a directory and accessing it

Open your favorite terminal. The terminals are different for Windows and Linux/Mac. Linux/Mac can run the same commands most of the time because they are inspired by UNIX so they are remarkably similar.

Create a directory with the command mkdir followed by the name of the directory, for example:

mkdir test1

And navigate into the directory with cd followed by the name of the directory:
cd test1

Start npm

If you nave Node/NPM the easiest part is to create an NPM project itself. Just run:
````npm init```

Your console will ask for information regarding your projects, such as name, author, and version. To be honest for my personal project I just skip it all by repeatedly pressing Enter on the keyboard, because most projects are just experiments that I will throw away once I can satisfy my curiosity about how to do something.

image.png

The next steps

The next steps are to get the packages you want from NPM:
https://www.npmjs.com/

With the command npm i followed by the name of your package.

In the next tutorial I will talk about APIs and how to create a simple API, this will teach how to work with packages and how network communication is done one node. I hope the next part is going to be up by tomorrow.

Click here and vote me for witness on HiveSigner

Or use your preferred signing tool to vote me:


https://vote.hive.uno/@igormuba



0
0
0.000
0 comments