How to learn Node.JS & Save some disk space

How to learn Node.JS & Save some disk space

<em>This article has been republished from </em><a href="https://medium.com/@dendybsulistyo/how-to-learn-node-js-save-some-disk-space-651e97fc668c" target="_blank"><em>medium.com</em></a>

This article has been republished from *[medium.com](https://medium.com/@dendybsulistyo/how-to-learn-node-js-save-some-disk-space-651e97fc668c "*medium.com")

For beginners, when you start to learn Node.JS, it’s very common to do all like these :

  • create folder, eg: mkdir hello-world-one

  • cd ***hello-world-one***

  • type npm init and answer some questions

  • after finished npm init

  • with an editor, we create helloone.js file like what you typed when answering *npm init *command

  • edit helloone.js

  • and run with node*** helloone.js***

  • open browser, and check url localhost:port-number, eg : localhost:3000

and then, if want to create more Node.JS app, you do those steps again, one more time,

  • create folder, eg: mkdir hello-world-two

  • cd ***hello-world-two***

  • type npm init and answer some questions

  • after finished npm init

  • with an editor, we create hellotwo.js file like what you typed when answering *npm init *command

  • edit hellotwo.js

  • and run with node ***hellotwo.js***

  • open browser, and check url localhost:port-number, eg : localhost:3000

On those two steps, when you create a very basic Node.JS application, you could possibly installed the same npm modules multiple times, like :

npm install express** on *hello-world-one*** folder and

npm install express** on *hello-world-two*** folder.

on limited and expensive SSD drive, node_modules folder could be a victim for disk space waste,

Now, try to save some disk space

Now we create a folder named *hello-worlds, eg : mkdir **hello-worlds***

  • cd ***hello-worlds***

  • type npm init and answer some questions

  • after finished *npm init *your package.json could be looks like :

    {> “name”: “helloworlds”,> “version”: “1.0.0”,> “description”: “”,> “main”: “helloworlds.js”,> “scripts”: {> “test”: “echo \”Error: no test specified\” && exit 1"> },> “author”: “Dendy B. Sulistyo”,> “license”: “ISC”,> “dependencies”: {> “express”: “ ^ 4.16.4”> }> }

  • create helloone.js and hellotwo.js

  • run npm install express

so.. now you only have one folder with two js files, before you run

node helloone.js

dont forget to edit your package.json file first, change helloworlds.js to helloone.js *and vice versa for *hellotwo.js file.

before run node hellotwo.js , change package.json *file, replace *helloworlds.jswith *hellotwo.js *, save and run

node hellotwo.js

now check your disk usage when you use this way.

on a big project and more npm modules, you will save a lot of disk space.

by the way, when you create small project, package.json files is not so important, but when your project grow up, and you need more npm modules, the main line and the dependencies line are important to focus related to the needs of npm modules ( node_modules )

lets try and save some space.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top 7 Most Popular Node.js Frameworks You Should Know

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser. In this post, you'll see top 7 of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).

Node.js for Beginners - Learn Node.js from Scratch (Step by Step)

Node.js for Beginners - Learn Node.js from Scratch (Step by Step) - Learn the basics of Node.js. This Node.js tutorial will guide you step by step so that you will learn basics and theory of every part. Learn to use Node.js like a professional. You’ll learn: Basic Of Node, Modules, NPM In Node, Event, Email, Uploading File, Advance Of Node.

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.