svg
Post Image
By Daniel Tanque17 de Outubro, 2023In LearningNodejs

Basics of Nodejs Apps

Node.js is an open-source, cross-platform JavaScript runtime environment that allows developers to run JavaScript code on the server-side. It is built on Chrome’s V8 JavaScript engine and provides an event-driven, non-blocking I/O model that makes it well-suited for building scalable network applications.

In this article you will learn how to setup nodejs in your system, and the use package manager.

Nodejs Setup

Javascript brought the dynamic websites, before that they were pretty static, but javascript change that and evolved from a client-side to a server side with nodejs.

To install nodejs you run:

curl -sL https://rpm.nodesource.com/... | bash -
yum install nodejs

For more info on versions and how to download you can you use this website: https://downloads.nodesource.com/

To check the installed version you run:

node -v

To run a node.js program you run:

node <js file>

Understanding the NPM

When you install node it already brings npm. Npm provides packages that can be installed for a project or also for a system, in order to install a package locally or globally you have to run:

npm install <package name> //for a project
npm install <package name> -g //for a global project, may require using "sudo"

Also you can check your npm version with the following command:

npm -v

If you want to know more about a package you can run

npm search <package name>

All the dependencies are present in the package.json file.

And once you install locally the package stays:

  • If local: /node_modules
  • If global: /usr/lib/node_modules

Conclusion

Now you know how to setup your node environment on you system and use the package manager. It will be useful on setting up docker, and on CICD.

svgBasics of Java Apps
svg
svgBasics of Python Apps

Leave a reply