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.

node-js javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.

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).

Hire Node.JS Developers | Skenix Infotech

We are providing robust Node.JS Development Services with expert Node.js Developers. Get affordable Node.JS Web Development services from Skenix Infotech.

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.

Hands on with Node.Js Streams | Examples & Approach

The practical implications of having Streams in Node.js are vast. Nodejs Streams are a great way to handle data chunks and uncomplicate development.