Home Web Front-end Front-end Q&A Nodejs decompressed version installation and environment configuration

Nodejs decompressed version installation and environment configuration

May 08, 2023 pm 07:16 PM

With the rapid development of Node.js, it has become one of the favorite server-side environments for JavaScript developers. Node.js is designed to be non-blocking and event-driven, which allows it to handle large amounts of I/O operations without causing blocking. Use Node.js to quickly build highly scalable web applications such as websites, APIs, and real-time communications applications. In this article, we will learn how to install and configure an unpacked Node.js environment.

  1. Download Node.js

First, you need to visit the official website of Node.js (https://nodejs.org/en/) and go to the download page Select the unzipped version of Node.js. Choose the correct version based on your operating system. For example, for Windows 64-bit operating system please download "Windows Binary (.tar.xz) 64-bit". When the download is complete, extract the installation package to any location on your local drive.

  1. Configuring environment variables

The decompressed version of Node.js requires manual configuration of environment variables to make the command line tool node and NPM commands available in any folder.

(a) Windows environment variables

Open Control Panel->System and Security->System->Advanced System Settings->Environment Variables. In System Variables, select the "Path" option and edit it. Use the "New" button to add the Node.js installation path, for example: "D:
odejs", and then save the changes.

(b) Linux environment variables

When you unpack Node.js on a Linux system, you need to edit the .bashrc file to configure the environment variables. To edit the .bashrc file, use the following command:

$ sudo nano ~/.bashrc

Add the following line at the bottom of the file:

export PATH=$PATH: /opt/nodejs/bin

Save the file and execute the following command to load the .bashrc:

$ source ~/.bashrc

Now you can access node and NPM from the terminal Order. Run the following command to check if they are available:

$ node -v

$ npm -v

If you successfully installed and configured the environment variables, you will see the installed Node.js and NPM version numbers.

  1. Using Node.js

Using the unpacked Node.js installer, you can now use Node.js to develop JavaScript-based web applications. By using Node.js, you can create server-side applications by creating JavaScript modules that contain network requests, I/O operations, and other functionality. In this section, we will introduce some important concepts of Node.js and write a simple "Hello World" application.

(a) Writing a "Hello World" Application

Open a console or terminal in a location of your choice and enter the following code:

$ mkdir myapp

$ cd myapp

$ echo "console.log('Hello World')" > app.js

After installing Node.js, you need to create a new folder ( For example "myapp"), and create a file named app.js, add the following code in it:

console.log('Hello World');

(b) Run the application Procedure

In the console or terminal, run the application using the following command:

$ node app.js

If you see the output of "Hello World!" So you have successfully run a simple Node.js application! congratulations!

(c) More complex applications

Now you have the basics of creating and running a simple Node.js application. You can combine other Node.js modules to achieve richer functions, or use some popular frameworks such as Express development to take full advantage of Node.js.

Conclusion

In this article, we introduced in detail how to install and configure the environment of the unpacked version of Node.js, and showed how to write and run Node.js applications. If you want to delve deeper into Node.js, please refer to the official Node.js documentation, or use other resources in the community. Node.js is a very powerful and widely used technology, and more and more companies and communities are actively contributing and developing it.

The above is the detailed content of Nodejs decompressed version installation and environment configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you connect React components to the Redux store using connect()? How do you connect React components to the Redux store using connect()? Mar 21, 2025 pm 06:23 PM

Article discusses connecting React components to Redux store using connect(), explaining mapStateToProps, mapDispatchToProps, and performance impacts.

React's Role in HTML: Enhancing User Experience React's Role in HTML: Enhancing User Experience Apr 09, 2025 am 12:11 AM

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

What are the limitations of Vue 2's reactivity system with regard to array and object changes? What are the limitations of Vue 2's reactivity system with regard to array and object changes? Mar 25, 2025 pm 02:07 PM

Vue 2's reactivity system struggles with direct array index setting, length modification, and object property addition/deletion. Developers can use Vue's mutation methods and Vue.set() to ensure reactivity.

How do you define routes using the <Route> component? How do you define routes using the <Route> component? Mar 21, 2025 am 11:47 AM

The article discusses defining routes in React Router using the &lt;Route&gt; component, covering props like path, component, render, children, exact, and nested routing.

What are Redux reducers? How do they update the state? What are Redux reducers? How do they update the state? Mar 21, 2025 pm 06:21 PM

Redux reducers are pure functions that update the application's state based on actions, ensuring predictability and immutability.

What are the benefits of using TypeScript with React? What are the benefits of using TypeScript with React? Mar 27, 2025 pm 05:43 PM

TypeScript enhances React development by providing type safety, improving code quality, and offering better IDE support, thus reducing errors and improving maintainability.

What are Redux actions? How do you dispatch them? What are Redux actions? How do you dispatch them? Mar 21, 2025 pm 06:21 PM

The article discusses Redux actions, their structure, and dispatching methods, including asynchronous actions using Redux Thunk. It emphasizes best practices for managing action types to maintain scalable and maintainable applications.

How can you use useReducer for complex state management? How can you use useReducer for complex state management? Mar 26, 2025 pm 06:29 PM

The article explains using useReducer for complex state management in React, detailing its benefits over useState and how to integrate it with useEffect for side effects.

See all articles