The difference between dependencies and devDependencies in package.json

The file package.json is an integral part of every Node.js project. It stores all the dependencies that your project needs. All the dependencies (most often open-source npm modules) are split into two categories: production dependencies and development dependencies....

June 2, 2022 路 2 min 路 Coderslang Master

What is the --save option for npm install

The --save option for npm install or npm i allows you to add the npm module you鈥檙e installing to the file package.json. This way it鈥檒l become one of the project dependencies and will be automatically installed the next time you run npm install....

May 9, 2022 路 1 min 路 Coderslang Master

What is the difference between ~ and ^ in package.json?

Node package manager supports semantic versioning. To take full advantage of it, you can use the symbols tilde(~) or caret(^). Tilde(~) means approximately equivalent to version. "moment": "~2.29.1" In this example npm install will pick up the latest release of the module moment starting from 2....

February 19, 2022 路 1 min 路 Coderslang Master

How to access command-line arguments in Node.js

In Node.js the command-line arguments are captured in the object process.argv. Let鈥檚 start by logging them to the screen. console.log(process.argv); If you run your script without any arguments, the output will be something like this....

January 19, 2022 路 1 min 路 Coderslang Master

How to update Node.js

In the past, updating Node.js was not straightforward as you had to install third-party software and run command lines which can be confusing and introduce bugs to your projects. Nowadays, It鈥檚 easy to update Node....

August 9, 2021 路 1 min 路 Coderslang Master

JSON Tutorial for JavaScript and Node.js

One of the most popular formats for exchanging data between backend and frontend is JSON which stands for JavaScript Object Notation. It is very similar to what regular JavaScript objects look like, but it also has its own quirks....

March 5, 2021 路 4 min 路 Coderslang Master

Node.js, Express Middleware and External Access

Great, we already have a production server and have done some tasks to better understand how it works. Now let鈥檚 take a look at middleware - one of the most important concepts of Express....

March 4, 2021 路 4 min 路 Coderslang Master

Create your first Node.js server with Express backend

In the last lecture, you saw the server-side analogy of the Hello, world that you wrote as your first task in VSCode. Our program was able to process the request and return a response, which was displayed by the browser....

March 3, 2021 路 3 min 路 Coderslang Master

What is rimraf and how to use it in Node.js

The rimraf command is an alternative to the Linux command rm -rf. It allows you to do deep recursive deletion of files and folders. Global rimraf installation You can install rimraf globally using npm....

February 8, 2021 路 1 min 路 Coderslang Master

How to fix the error `require is not defined` in Node.js

Today I started writing a new project on Node.js and got this error on the very first run: const express = require('express'); ^ ReferenceError: require is not defined at ModuleJob.run (node:internal/modules/esm/module_job:152:23) at async Loader....

February 2, 2021 路 2 min 路 Coderslang Master