The node_modules folder is often super big and contains countless files and subdirectories. Therefore, when using the tree command to display your project file structure, you should ignore node_modules. To do so, try this: tree -I......
A few easy-to-understand examples that will help you understand “exports” and “require” in Node.js better. Example 1 Exports: // your-file.js const firstMethod = () => { // do something } const......
If you’re working with PostgreSQL or MySQL and making use of TypeORM in your code then you can add a column with the ENUM (enumerated) data type like so: // book.entity.ts import { Entity, PrimaryGeneratedColumn, ......
In TypeORM, you can add a created_at column and a updated_at column by making use of the CreateDateColumn and UpdateDateColumn decorators, respectively. These columns will be automatically initialized and updated to the current date......
There might be times when you might want to export something based on one or multiple conditions (for example, you want to export configuration information like database, API keys, etc for development environment and production......
To show all globally installed npm packages on your computer, just run the following command: npm list -g --depth 0 Here is my output: /usr/local/lib ├── @nestjs/[email protected] ├── [email protected] ├── [email protected] ├──......
In Node.js, you can compress a file using the Gzip format by using streams. We can get the job done with just a few lines of code and there is no need to install any third-party packages. Example: // Kindacode.com Example const......
Buffers and strings in Node.js are limited in size. The actual maximum size of a buffer or a string changes across platforms and versions of Node.js. You can check yours as follows: const buffer = require('buffer'); // Get the......
The example below shows you how to change the behavior of a Node.js core module by modifying or extending it. What we are going to do should not appear in serious products but might be somehow helpful for learning and testing......
The example below shows you how to programmatically generate images from text in Node.js by using the canvas library. Example Here’s the image we are going to “draw” with code: The code 1. Install the......
In Node.js, we can use the setTimeout function to run a piece of code after a delay. You can call setTimeout directly or use it with async/await. Example 1 – setTimeout This code runs a function named sayHello after 1000......