Install nodejs on Amazon EC2 Linux machine

Problem

You may encounter the following error while installing Node.js on Linux under an Amazon EC2 instance:

node: /lib64/libm.so.6: version GLIBC_2.27′ not found (required by node)

node: /lib64/libc.so.6: version GLIBC_2.28′ not found (required by node)

Reason

The reason for these issues is that your machine is running ldd (GNU libc) version 2.26 by default. If you are installing Node.js LTS version 18 or above, you will encounter these errors.

Solution

tl;dr

Install node 16 instead of LTS

Here are the steps to install Node.js using NVM on your EC2 instance:

  1. Update the package manager’s cache:sudo yum update
  2. Install the dependencies required for NVM:sudo yum install -y gcc-c++ make
  3. Download and install NVM:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  4. Activate NVM by sourcing the ~/.bashrc file:source ~/.bashrc
  5. Install the LTS version of Node.js using NVM:nvm install 16
  6. Set the installed Node.js version as the default:nvm alias default stable
  7. Verify the installation by checking the Node.js and npm versions:node -v npm -v

By following these steps, you will have installed Node.js on your EC2 instance using Node Version Manager (NVM).

Upgrading to React 18: Migrating from ReactDOM.render

Introduction: React 18 brings exciting new features and optimizations, but with it comes the deprecation of ReactDOM.render, a commonly used method for rendering React components. In this blog post, we’ll explore the changes introduced in React 18 and guide you through the process of migrating away from ReactDOM.render to leverage the latest rendering capabilities. By the end, you’ll have a solid understanding of the deprecation and be well-equipped to upgrade your React applications.

  1. Understanding the Deprecation:
    • Explaining the rationale behind deprecating ReactDOM.render in React 18.
    • Highlighting the benefits of the new rendering approach.
  2. Introducing React 18’s New Rendering Model:
    • Exploring the concept of Concurrent Mode and its impact on rendering.
    • Understanding the new root and render APIs introduced in React 18.
  3. Handling Common Migration Challenges:
    • Addressing potential pitfalls and obstacles during the migration process.
    • Providing solutions to common issues encountered when updating existing codebases.
  4. Leveraging the Benefits of React 18:
    • Showcasing the performance improvements and enhanced user experience.
    • Highlighting the advantages of adopting React 18’s new rendering capabilities.
  5. Optimizing React 18 Applications:
    • Exploring additional optimizations and best practices for React 18.
    • Discussing performance tuning techniques to maximize the benefits.
  6. Resources and Tooling:
    • Sharing useful resources, documentation, and guides for React 18 migration.
    • Introducing relevant tools and libraries that assist with the upgrade process.
// Before React 18
import React from 'react';
import ReactDOM from 'react-dom';

const App = () => {
  return <h1>Hello, World!</h1>;
};

ReactDOM.render(<App />, document.getElementById('root'));
// After React 18
import React from 'react';
import { render } from 'react-dom';

const App = () => {
  return <h1>Hello, World!</h1>;
};

render(<App />, document.getElementById('root'));

Conclusion: With the deprecation of ReactDOM.render in React 18, it’s essential to understand the new rendering model and migrate your code accordingly. By embracing the latest features and optimizations offered by React 18, you can unlock enhanced performance and deliver a superior user experience. Follow the steps outlined in this blog post, and you’ll be well on your way to upgrading your React applications successfully.