NodeJS Basic (console) Syntax

You requested, i delivered. Today we are going to take a look at the complete basics of NodeJS Usage. Let's go!


Starting a project

Every project in NodeJS starts with a file named package.json, this file is basically the heart of your project - no files will work without it.

You start your project by navigating to your project's folder using cd DIRECTORY NAME, and then running npm init. Now you just simply follow the instructions in terminal, and your project is started. Now you just have to create some .js files and start coding.

When you want to run your project, you will want to use either node FILENAME or PM2, but PM2 is not a beginner feature.


Installing and updating packages

Note: All of those commands have to be executed after CDing to the folder.

In most cases, you will want to use packages to speed up your workflow and write less code. You can install some by using npm i PACKAGENAME, you can search packages HERE.

If you want to check for outdated packages, use npm outdated. Outdated packages will show up red in your terminal. (if using VSC integrated terminal, I am not 100% sure about other CMD lines/terminals).
To update your packages, use npm update.


Stopping a process

On OSX: CTRL + C or exit in console
On Win: CTRL + C (might need to press 2 times), CTRL + D or exit in console


I told you it is going to be basic, now get to coding! If you have any questions, be sure to contact us on discord!