Get started with Node.js

Amitesh Kumar
Web For You
Published in
2 min readJun 16, 2020

So today i started learning about node.js. I have no background in the field of backend. So i decided to go with node.js. Node.js is an opensource server environment which can be run on any platform(windows,linux,unix,max etc.).It uses javascript on the server.Major work of this is to open a file on the server and return the content to the client.It is memory efficient and fast.

We can use Node.js to collect form data,add delete,modify data in our database.

So here is my summary for Day 1:

1> Module.exports : This is a special object which is included in every js file in the Node.js application by default. Here module represents the current module and exports is and object that will be exposed as a module. In short whatever we assign to module.exports , it will be exposed as a module. let us take an example : in one file(example : hello.js) you write module.exports=”Hello world”; and you want to use this in your app.js file so now you import this module by writing the following command in app.js: const message=require(‘./hello.js’); console.log(message) and thus your message will be printed in the console. Now question comes why we used ‘./’ this is mainly for specifying it as a path of root folder to import a local module.We do not need to specify this for node.js inbuilt modules.

I gave example of a message but you can export anything from other files as modules like functions,objects etc..

example for module.export from other file
From here the above image is importing modules.(ref: freecodecamp)

Its quite simple but to know more about this you can read more on w3schools site about introduction to node js and also about module.exports.

--

--

Amitesh Kumar
Web For You

A web developer to be…sharing whatever I learn.