JavaScript

Fixing “error: cannot find module semver” error in Node.js

Fixing “error: cannot find module semver” error in Node.js

  • October 19, 2023

When installing a package using npm, you might encounter the “error: cannot find module semver” error. The error is caused because of a corrupted package-lock.json or yarn.lock. The most common reason for this is a change in the node version. Fixing “error: cannot find module semver” The fix is a...

Fix “Error:0308010C:digital envelope routines::unsupportedFixing” in Node.js

Fix “Error:0308010C:digital envelope routines::unsupportedFixing” in Node.js

  • October 17, 2023

Node 17 introduced OpenSSL v3.0, which brought in some breaking changes, and the “Error: error:0308010C:digital envelope routines::unsupported” is a result of one such change. It can be solved by passing in a “–openssl-legacy-provider” flag when running the application. Setting the NODE_OPTIONS environment variable We can set the environment variable that...

How to sort a Set in JavaScript

How to sort a Set in JavaScript

  • November 26, 2022

ES6 introduced the set data structure in JavaScript. But sets are not ordered abstract data structures. So there is no .sort() property available on them. To sort a Set in JavaScript, we need to convert it into an array first. Since arrays are sortable, we will then sort them, and...

Deep copying in JavaScript using structuredClone

Deep copying in JavaScript using structuredClone

  • August 23, 2022

For as long as anyone can remember, deep copying in JavaScript was not a built-in feature and we had to resort to libraries or workarounds to create a deep copy of a JavaScript value. That has changed now. The platform now offers a built-in function that does deep copying for...

Chrome devtools: Using logpoints for logging messages directly

Chrome devtools: Using logpoints for logging messages directly

  • March 24, 2022

When it comes to debugging JavaScript in Chrome devtools, there are two different camps: the console.log fans and the debugger/breakpoint maximalist. I often switch between the two depending on what problem I am tackling. There is a third option that is kind of in the middle. Logpoints provide us with...