ssh install nodejs

王林
Release: 2023-05-13 20:07:40
Original
643 people have browsed it

SSH installation Node.js

Node.js is a JavaScript running environment based on the Chrome V8 engine, which allows JavaScript to be run, developed and debugged on the server side without the browser. In this article, we will explain how to install Node.js on an SSH terminal.

Step 1: Log in to the SSH terminal

First, you need to log in to your server using an SSH terminal. You can connect to your server using PuTTY (Windows), Terminal (macOS), or ssh (Linux). After successfully logging in, you are in a remote terminal command line environment.

Step 2: Add Node.js source

The developers of the Debian system maintain the apt source of Node.js. We can let the system automatically update and install by adding the address of the source. Enter the following command to add the official Node.js source:

curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
Copy after login

This command will download and run a shell script. This script will add a Node.js source.

Step Three: Install Node.js

Run the following command to upgrade and install Node.js:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nodejs
Copy after login

During the installation process, the system will install Node on your system .js and npm (Node.js package manager).

You can also check the installed versions of Node.js and npm by running the following commands:

node -v
npm -v
Copy after login

Step 4: Use Node.js to run JavaScript files

After installation After finishing Node.js, you can enter the following command to verify whether Node.js was successfully installed:

node -e "console.log('Hello World!')"
Copy after login

This will output the text "Hello World!"

If you want to run the JavaScript file, you can use the following command:

node /path/to/your/file.js
Copy after login

This command will run your file in the terminal.

Conclusion

You can easily install Node.js on an SSH terminal by adding the official Node.js source and installing using apt-get. Additionally, you can use Node.js to run and test JavaScript code from an SSH terminal, as well as use npm to manage your programs and packages.

The above is the detailed content of ssh install nodejs. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!