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 -
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
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
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!')"
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
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!