Install NextJs in linux

To install Next.js on a Linux system, you’ll first need Node.js and npm (Node Package Manager) installed. Here’s a step-by-step guide:

  1. Install Node.js and npm:
    • You can check if Node.js is already installed by running node -v and npm -v. If not, you can install Node.js using a package manager or by downloading it from the official website.
    Using a package manager (example for Debian/Ubuntu):

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

Create a new directory for your Next.js project: You can create a new directory where your Next.js project will reside. For example:

mkdir my-nextjs-app
cd my-nextjs-app

Initialize a Node.js project: Inside your project directory, you need to initialize a Node.js project. This will create a package.json file.

npm init -y

Install Next.js and React: Install Next.js and React as dependencies for your project:

npm install next react react-dom

Create a Next.js application: You can start a new Next.js app using the create-next-app tool. First, you need to install it globally (you can also use npx):

npm install -g create-next-app

Then, create your Next.js app:

npx create-next-app .

Run your Next.js app: You can now start your Next.js app with the following command:

npm run dev

This will start the development server, and you can access your Next.js app in a web browser at http://localhost:3000.

Leave a comment

Your email address will not be published. Required fields are marked *