--- title: "Install Node.js and npm" description: "Install Node.js and npm on a CentOS or RHEL node from the package source that matches your OS, then confirm it works with a small test server." content_type: "how-to" product: "node" platform: "MyAccount" url: "/myaccount/node/how-to/install-nodejs-and-npm/" topic: ["create-and-connect"] --- # Install Node.js and npm A common follow-up to launching a CentOS or RHEL node is installing Node.js to run an application. Use the package source that matches your OS version and what your application needs. Skip the old Node.js 6.x setup scripts; they are obsolete. Log into the node as root first. See [Connect to a Linux node](/myaccount/node/how-to/connect-to-a-linux-node). ## Check which Node.js stream your OS offers ```bash frame="none" dnf module list nodejs ``` ## Install Node.js and npm together ```bash frame="none" dnf install -y nodejs npm ``` On an older CentOS image that still uses `yum`, install with: ```bash frame="none" yum install -y nodejs npm ``` ## Check the Node.js and npm versions ```bash frame="none" node -v ``` ```bash frame="none" npm -v ``` ## Confirm the install with a small test server Create a file: ```bash frame="none" vim test_server.js ``` Add this content: ```javascript const http = require("http"); http .createServer((req, res) => { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Welcome"); }) .listen(3001, "127.0.0.1"); console.log("Server running at http://127.0.0.1:3001/"); ``` Start it: ```bash frame="none" node test_server.js ``` You see `Server running at http://127.0.0.1:3001/`, and visiting that address inside the node returns `Welcome`. Node.js and npm are ready to use. If a change here leaves the node unreachable, see [Troubleshooting node networking and connectivity](/myaccount/node/troubleshooting/networking-and-connectivity).