Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 4. Node.js basics in CodeReady Studio


Node.js is an event-based, asynchronous I/O framework and is used to develop applications that run JavaScript on the client and server side. This allows the application to reuse parts of the code and to avoid switching contexts. Node.js is commonly used to create applications such as static file servers, messaging middleware, HTML5 game servers, web application framework, and others.

CodeReady Studio supports Node.js application development using the npm package installer and offers a built-in debugging tool to identify and fix issues with applications.

The following section describes how to:

  • Create a new JavaScript project.
  • Create a new package.js file.
  • Create a new JavaScript file.
  • Import an existing JavaScript project.
  • Run a Node.js application.

Prerequisites

  • Installed npm.
  • Installed Node.js.

    To install the prerequisites, on RHEL 7, use:

    # yum install npm nodejs
    Copy to Clipboard Toggle word wrap

    To install the prerequisites, on RHEL 8, use:

    # dnf install npm nodejs
    Copy to Clipboard Toggle word wrap

4.1. Creating a new JavaScript project

The following section describes how to create a new JavaScript project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Click File New Other.

    The New window appears.

  4. Enter JavaScript in the search field.
  5. Select JavaScript Project.
  6. Click the Next button.

    The Create a JavaScript project window appears.

  7. Name your project.

    All other fields are populated automatically.

  8. Click the Finish button.

    The Open Associated Perspective window appears.

  9. Click the Open Perspective button.

Your newly created JavaScript project is now listed in the Project Explorer view.

4.2. Creating a package.js file

The following section describes how to create a new package.json file in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Click File New Other.

    The New window appears.

  4. Enter npm in the search field.
  5. Select npm Init.
  6. Click the Next button.

    The npm Initialization Wizard window appears.

  7. Click the Browse Workspace button to select the base directory for the package.json file.
  8. Click the Finish button.

    The Open Associated Perspective window appears.

  9. Click the Open Perspective button.

Your newly created package.js file is now displayed in the CodeReady Studio editor.

Additional resources

4.3. Creating a new .js file

The following section describes how to create a new .js file CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Click File New File.

    The Create New File window appears.

  4. Select a parent folder for the file.
  5. Name the file.

    For example index.js.

  6. Click the Finish button.

Your newly created .js file is now displayed in the CodeReady Studio editor.

4.4. Importing an existing Node.js application

The following section describes how to import an existing Node.js application.

Procedure

  1. Start CodeReady Studio.
  2. Click File Import.

    The Import window appears.

  3. Expand the General folder.
  4. Select Existing Project into Workspace.
  5. Click the Next button.
  6. Click the Browse button to locate your existing project.
  7. Select the path to your project in the Projects field.
  8. Click the Finish button.

Verification steps

  1. Click Window Perspective Open Perspective Other.

    The Open Perspective window appears.

  2. Select JavaScript.
  3. Click the Open button.

    The Project Explorer view appears.

Your newly imported Node.js application is now listed in the Project Explorer view.

4.5. Running a Node.js application

The following section describes how to run a Node.js application in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Git Perspective.
  3. Open Project Explorer.
  4. Right-click target project Run as Node.js Application.

The Console opens running your Node.js application.

4.6. Debugging a Node.js application

CodeReady Studio includes a debugger to help identify and resolve the issues.

The following section describes how to debug Node.js applications in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Open Project Explorer.
  3. Expand the target project.
  4. Right-click the index.js Debug as Node Program.

    The Console appears, displaying the error log.

Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat