Compile Node.js With NPM From Source - CentOS or Fedora

While it is generally recommended that you use the more traditional Node.js install methods, you may want to instead compile Node.js from source if you need more direct control over your Node.js environment or you want to use a custom-compiled version.


  • A CentOS or Fedora Server.
  • Root or sudo permissions.
  1. Update your repositories:
    sudo yum update
  2. Install gcc:
    sudo yum install gcc gcc-c++ automake autoconf libtoolize make
  3. Change to the optdirectory:
    cd /opt
  4. Copy the Linux Binary from the Node.js download page, and use wget to download the package. Make sure to replace the highlighted portion with node's current version:
    sudo wget
  5. Extract the tar file:
    sudo tar zxvf node-v6.9.2.tar.gz
  6. Now that our source code has been extracted, move to the node directory where the highlighted portion is the current version you downloaded:
    cd node-v6.9.2

    Note: This folder contains raw files that need to be compiled specifically for your particular architecture and kernel. Most source code packages like this come with a bash script called "configure" that will create all these files and set the options for you.

  7. Run the configure script:
    sudo ./configure
  8. Note: If you don't receive any errors or warnings, the the configure script ran successfully.

  9. Compile the code:
    sudo make

    make will begin compiling the code. This will take 5-10 minutes or even longer depending on your server.

  10. Now that make is compiled, install it:
    make install
  11. Check the Node.js version:
    node --version
  12. Check the npm version:
    npm --version
  13. If you see the versions displayed for node and npm, you have successfully compiled Node.js with npm from source. You can now begin installing node modules through npm.

Next step

More info

Apakah Artikel Ini Berguna?
Terima kasih atas masukan Anda. Untuk berbicara dengan perwakilan layanan pelanggan, hubungi nomor ponsel dukungan atau gunakan opsi chatting di atas.
Senang bisa membantu! Ada hal lain yang dapat kami lakukan untuk Anda?
Maaf tentang hal tersebut. Sampaikan apa yang membuat Anda bingung atau mengapa solusi tersebut tidak mengatasi masalah Anda.