NodeJs – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Thu, 15 Dec 2022 07:59:36 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to list all collections in MongoDB database https://tecadmin.net/how-to-list-all-collections-in-mongodb-database/ https://tecadmin.net/how-to-list-all-collections-in-mongodb-database/#respond Sat, 30 Jul 2022 06:17:58 +0000 https://tecadmin.net/?p=30791 Question – How do I list all the collections available in the MongoDB database? MongoDB is a NoSQL database, that stores documents in JSON format. A collection is an entity in MongoDB (ie similar to a table in RDBMS databases) that stores JSON documents. You can use one of the below options to list collections [...]

The post How to list all collections in MongoDB database appeared first on TecAdmin.

]]>
Question – How do I list all the collections available in the MongoDB database?

MongoDB is a NoSQL database, that stores documents in JSON format. A collection is an entity in MongoDB (ie similar to a table in RDBMS databases) that stores JSON documents.

You can use one of the below options to list collections in a MongoDB database.

  • Mongo Shell: You can use one of the following commands from Mongo Shell to list all available collections in the MongoDB database. Before running the below commands you must be connected with the target database using use database_name.
    show collections 
    
    show tables 
    
    db.getCollectionNames() 
    
  • Node.js: Use listCollections() method to list all collections in database with Node.js application. The application must have created a connection to the MongoDB database before.
    db.listCollections()
    
  • JavaScript Shell: The JavaScript shell users can use the following method to list collections in the MongoDB database.
    db.getCollectionNames()
    

Thanks, hope this quick how-to guide helps you to find all collections in a MongoDB database.

The post How to list all collections in MongoDB database appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-list-all-collections-in-mongodb-database/feed/ 0
Running “npm start” with PM2 https://tecadmin.net/running-npm-start-with-pm2/ https://tecadmin.net/running-npm-start-with-pm2/#respond Wed, 13 Jul 2022 05:24:58 +0000 https://tecadmin.net/?p=30546 PM2 is an advanced process manager for running Node.js applications. That provides an easier option to automate a Node.js application. We can quickly do the start, stop, or other operations on applications. Many of the Node.js applications use “npm start” to run. In this quick how-to guide, we will help you to run “npm start” [...]

The post Running “npm start” with PM2 appeared first on TecAdmin.

]]>
PM2 is an advanced process manager for running Node.js applications. That provides an easier option to automate a Node.js application. We can quickly do the start, stop, or other operations on applications. Many of the Node.js applications use “npm start” to run. In this quick how-to guide, we will help you to run “npm start” using pm2.

Assuming that you already have Node.js installed on your system. If you haven’t already, visit our tutorial to install Node.js using nvm.

  1. Installing PM2: Make sure you have installed PM2 globally on your machine with this command:
    npm install pm2 --location=global 
    

    After installing pm2, run “pm2 startup” once to configure auto-start pm2 during system reboot.

  2. Start npm: PM2 also supports to run npm start:
    pm2 start npm -- start 
    

    Use the --name option to assign a name to the PM2 process.

    pm2 start npm --name "my_app" -- start 
    
  3. List all service running with pm2
    pm2 list 
    

Hopefully, this article helped you to run the NPM application using the pm2 process manager.

See the screenshots of running npm start with pm2.

How to run npm start using pm2
Running npm start with pm2

The post Running “npm start” with PM2 appeared first on TecAdmin.

]]>
https://tecadmin.net/running-npm-start-with-pm2/feed/ 0
How to Install Latest Node.js on Ubuntu https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/ https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/#comments Tue, 14 Jun 2022 13:10:38 +0000 https://tecadmin.net/?p=5145 If you’ve been exploring the world of front-end and JavaScript, you might have come across Node.js. It is a server-side framework that uses Google’s V8 engine to execute JavaScript code. Developers can use Node.js as it provides them with an easy way to build fast and scalable network applications, using single-threaded asynchronous events. In this [...]

The post How to Install Latest Node.js on Ubuntu appeared first on TecAdmin.

]]>
If you’ve been exploring the world of front-end and JavaScript, you might have come across Node.js. It is a server-side framework that uses Google’s V8 engine to execute JavaScript code. Developers can use Node.js as it provides them with an easy way to build fast and scalable network applications, using single-threaded asynchronous events.

In this article, we will see how to install Node.js on Ubuntu and its derivatives via a new official PPA repository. If you are new to Ubuntu or any other Linux operating system, then be sure to check out our beginner’s guide first.

You can also use the popular Node Version Manager (NVM) for installing specific Node.js version on your system.

Step 1 – Configuring Node.Js PPA

Node.js releases are available in two types, one is the LTS release, and the other is the current release. Choose any one version of your choice or as per the project requirements. Let’s add the PPA to your system to install Nodejs on Ubuntu.

  • Use Current Release – During the last update of this tutorial, Node.js 19 is the current Node.js version available.
    sudo apt install -y curl 
    curl -sL https://deb.nodesource.com/setup_19.x | sudo -E bash - 
    
  • Use LTS Release – Instead of the current release, it’s a good idea to use a stable version. During the last update of this tutorial, Node.js 18 is the latest LTS release available.
    sudo apt install -y curl 
    curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - 
    

For this tutorial, I am using the latest current release and added their PPA to my system.

Step 2 – Install Node.js on Ubuntu

You have successfully configured Node.js PPA in your Ubuntu system. Now execute the below command to install Node on Ubuntu using apt-get. This will also install NPM with node.js. This command also installs many other dependent packages on your system.

sudo apt install -y nodejs 

That’s it. This will install Node.js on your Ubuntu system.

Step 3 – Check Node.js and NPM Version

After installing node.js verify and check the installed version. You can find more details about the current version on node.js official website.

node -v

v19.2.0

Also, check the npm version

npm -v 

8.19.3

Step 4 – Create Demo Web Server (Optional)

This is an optional step. Suppose you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file server.js

sudo nano server.js 

and add the following content

server.js
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(3000, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3000/');

Save the file and close. Then start the Node application using the following command.

node server.js 

debugger listening on port 5858
Server running at http://127.0.0.1:3000/

You can also start the application with debugging enabled with the following commands.

node --inspect server.js

Debugger listening on ws://127.0.0.1:9229/938cf97a-a9e6-4672-922d-a22479ce4e29
For help, see: https://nodejs.org/en/docs/inspector
Server running at http://127.0.0.1:3000/

The web server has been started on port 3000. Now access http://127.0.0.1:3000/ URL in browser. Now you will need to configure a front-end server for your app.

Conclusion

In conclusion, we have seen how to install Node.js on Ubuntu and its derivatives via a new official PPA repository. This makes it easy for us to get started with Node.js development on our Linux systems. We can also use this repository to keep our installations up-to-date with the latest stable versions of Node.js. Be sure to check out other tutorials on our website for more tips and tricks about using Node.js!

The post How to Install Latest Node.js on Ubuntu appeared first on TecAdmin.

]]>
https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/feed/ 55
How To Install NVM on Ubuntu 22.04 https://tecadmin.net/how-to-install-nvm-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-nvm-on-ubuntu-22-04/#respond Thu, 07 Apr 2022 02:02:25 +0000 https://tecadmin.net/?p=28843 NVM is a Node Version Manager tool. Using the NVM utility, you can install multiple node.js versions on a single system. You can also choose a specific Node version for applications. It also provides an option to auto-select the node version using the .nvmrc configuration file. In this tutorial, we will help you to install [...]

The post How To Install NVM on Ubuntu 22.04 appeared first on TecAdmin.

]]>
NVM is a Node Version Manager tool. Using the NVM utility, you can install multiple node.js versions on a single system. You can also choose a specific Node version for applications. It also provides an option to auto-select the node version using the .nvmrc configuration file.

In this tutorial, we will help you to install NVM on Ubuntu 22.04 Linux system. Also, provide you with the instructions to install multiple Node.js versions with useful examples.

Prerequisites

  • You must have a running Ubuntu 22.04 Linux system with shell access.
  • Log in with a user account to which you need to install node.js.

Installing NVM on Ubuntu

A shell script is available for the installation of nvm on the Ubuntu 22.04 (Jammy Jellyfish) Linux system. Open a terminal on your system or connect a remote system using SSH. Use the following commands to install curl on your system, then run the nvm installer script.

sudo apt install curl 
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 

The nvm installer script creates an environment entry to the login script of the current user. You can either log out and log in again to load the environment or execute the below command to do the same.

source ~/.profile 

Installing Node using NVM

You can install any number of node.js versions of your requirements using nvm. Then you can use the required version for your application from installed node.js.

  • Install the latest version of node.js. Here node is the alias for the latest version.
    nvm install node 
    
  • To install a specific version of node:
    nvm install 16.14.0  
    

You can choose any other version to install using the above command. The very first version installed becomes the default. New shells will start with the default version of the node (e.g., nvm alias default).

Working with NVM

You can use the following command to list installed versions of the node for the current user.

nvm ls 

List available node.js versions for the installation.

nvm ls-remote 

You can also select a different version for the current session. The selected version will be the currently active version for the current shell only.

nvm use 16.14.0 

To find the default Node version set for the current user, type:

nvm run default --version 

You can run a Node script with the desired version of node.js using the below command:

nvm exec 16.14.0 server.js 

Conclusion

In this tutorial, you have learned to install nvm on Ubuntu 22.04 LTS (Jammy Jellyfish) Linux system. Also, get a basic understanding of the nvm uses.

The post How To Install NVM on Ubuntu 22.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-nvm-on-ubuntu-22-04/feed/ 0
How To Install NVM on Windows https://tecadmin.net/install-nodejs-with-nvm-on-windows/ https://tecadmin.net/install-nodejs-with-nvm-on-windows/#respond Fri, 04 Mar 2022 12:05:02 +0000 https://tecadmin.net/?p=24182 NVM (Node Version Manager) is the command-line utility for installing Node.js on your system. It allows us to install multiple Node.js versions and switch between them. This is helpful for the system running multiple Node applications that required different-2 node versions. This tutorial will help you to install and manage multiple Node.js versions on Windows [...]

The post How To Install NVM on Windows appeared first on TecAdmin.

]]>
NVM (Node Version Manager) is the command-line utility for installing Node.js on your system. It allows us to install multiple Node.js versions and switch between them. This is helpful for the system running multiple Node applications that required different-2 node versions.

This tutorial will help you to install and manage multiple Node.js versions on Windows using NVM.

How to Install NVM on Windows

The coreybutler has build the nvm installer for the Windows systems. Visit the below link to download the NVM installer for the Windows systems.

  • https://github.com/coreybutler/nvm-windows/releases
  • And download the nvm-setup.zip file of the latest version.

    How to Install Nvm on Windows
    Download NVM installer for Windows

    Extract the downloaded archive file from your system.

    You will get a node-setup.exe file under the archive file. Double click the node-setup.exe file to begin the Node installation on Windows.

    Follow the installation wizard to complete the installation of Node on Windows.

    How to Install NVM on Windows
    NVM Installation Finished on Windows

    Installing Node.js on Windows using NVM

    As you have already installed the NVM on your system. Now, you can install any version of Node.js on the Windows system. To install the most recent version use “latest” and to install latest stable version use “lts” with nvm install command.

    • Use the following command to install most recent Node.js version
      nvm install latest 
      

      How to Install Latest Node with NVM on Windows
      Installing Latest Node Version on Windows
    • To install the latest stable version, execute the following command
      nvm install lts 
      
    • Installing Latest Stable Node Version on Windows
      Installing Latest Stable Node Version on Windows
    • You can also install a specific version like 14.15.0.
      nvm install 14.15.0 
      

    You can follow the same commands to install multiple node versions on a single system.

    Setup Default Node.js Version

    You can change the default active Node version with the following command. For example, to setup Node 14.1.50 as default version, type:

    nvm use 14.15.0 
    

    Once the new version activated, type:

    node --version 
    

    This will show the current active Node.js version. See the below screenshot:

    How to Install Node.js on Windows
    Setup Default Node Version

    Uninstall Node Version

    You can remove unused older Node version’s from your system with the following command.

    nvm uninstall 14.15.0 
    

    Change the version number as per your requirements. The above command will remove Node 14.15.0 from your system.

    Conclusion

    This tutorial helped you for installing NVM on Windows system. Also provides you commands to install specific Node.js version on Windows system.

    Remember that the NVM is installed for a specific user. So to use NVM for another user, need to separately install it from that account.

    The post How To Install NVM on Windows appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-nodejs-with-nvm-on-windows/feed/ 0
    How To Install Node.Js on Debian 11 https://tecadmin.net/how-to-install-node-js-on-debian-11/ https://tecadmin.net/how-to-install-node-js-on-debian-11/#respond Sun, 19 Sep 2021 06:45:02 +0000 https://tecadmin.net/?p=27794 NodeJs is a JavaScript framework that allows users to easily develop autonomous network applications for general-purpose programming. NodeJs is free to make web application development more uniform and integrated through the use of JavaScript on both the front and back ends. It is available for all Operating Systems; in this article, you will learn how [...]

    The post How To Install Node.Js on Debian 11 appeared first on TecAdmin.

    ]]>
    NodeJs is a JavaScript framework that allows users to easily develop autonomous network applications for general-purpose programming. NodeJs is free to make web application development more uniform and integrated through the use of JavaScript on both the front and back ends.

    It is available for all Operating Systems; in this article, you will learn how to install NodeJs on your Debian system (Linux OS) so that you can build amazing applications using NodeJs.

    Given below are three methods to install NodeJs on Debian 11, you can follow any of these you find easier for successful installation:

    Method 1 – Installing Nodejs from Debian Repository

    At the time of writing this tutorial, the Node.js 12.22.5 version is available under default repositories. To get this version of NodeJs on your Debian system follow the steps mentioned below:

    1. Update Packages – First update all the packages previously installed in the System by below mentioned command:
      sudo apt update 
      
    2. Install Nodejs and NPM – The “npm” is the package manager of NodeJs, run the below mentioned command to install NodeJs and npm on Debian 11:
      sudo apt install nodejs npm 
      
    3. Check Version – To verify the correct version installation of NodeJs, run the below mentioned command to check version number of recently installed NodeJs:
      node -v 
      
      Output:
      v12.22.5

    Method 2 – How to install NodeJs using NodeSource PPA

    You can use a PPA (Personal Package Archive) provided by NodeSource to operate with the latest version of NodeJs. This is an alternative repository containing ‘Apt’ and contains current versions than the official Debian repositories for NodeJs.

    Follow the steps below for successful installation of NodeJs using PPA:

    1. Install PPA – To install NodeJs Package using “Apt”, add the repository to Package list using below-mentioned syntax:

      curl -sL https://deb.nodesource.com/setup_[version_number] -o nodesource_setup.sh

      You can replace “version number” with the version you want to install, here I am installing stable version “16.x” by below mentioned command:

      curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh 
      
    2. Configure NodeSource setup – Run the below mentioned to inquire newly downloaded script, it will open a file and after inspecting the file press Ctrl+X to exit the file and return to terminal:
      nano nodesource_setup.sh 
      
    3. Run the Script – After configuring the script, run the script using below mentioned command:
      sudo bash nodesource_setup.sh 
      

      The PPA is added to your settings and the local package cache is instantly updated.

    4. Install NodeJs – Now after adding PPA, install NodeJs using below mentioned command, we don’t need to install npm separately here as it is already included in package:
      sudo apt install nodejs 
      
    5. Check Version – Now verify installation by checking version number of NodeJs:
      node -v 
      
      Output:
      v16.14.0

      Also check version of npm to verify its installation with NodeJs:

      npm -v 
      
      Output:
      8.3.1
    6. Installing “build-essential” – To get the needy tools to work with npm package, run the below mentioned command:
      sudo apt install build-essential 
      

    Method 3 – Installing NodeJs using NVM on Debian 11

    Node Version Manager, abbreviated as NVM, can also be used to install NodeJs on Debian. Instead of functioning in the operating system, NVM operates in the home directory of your user at the level of an independent directory. In other words, without impacting the overall system, you may install numerous autonomous NodeJs versions.
    You may use NVM to control your environment while maintaining and handling prior releases in the latest NodeJs versions.

    Follow the steps given below to install NodeJs using NVM:

    1. Download NVM installation script – Firstly, from the GitHub link download the nvm installation script by the below-mentioned command:
      curl -sL https://raw.githubusercontent.com/creationix/nvm/master/install.sh -o install_nvm.sh 
      
    2. Configure script – Using nano command, inquire the downloaded script by below mentioned command:
      nano install_nvm.sh 
      

      After checking the file, if everything seems good then exit the editor by pressing Ctrl+X.

    3. Run the script – After configuring the file, run the downloaded script:
      bash install_nvm.sh 
      
    4. Gain Access to NVM Functionality – Running NVM script will add additional setup to “~/ .profile” , allowing the new program, you will either log out or log in back; reload “~/ .profile” file using:
      source ~/.profile 
      
    5. Install NodeJs from available versions on NVM –
      First, we can check which versions of NodeJs are available on NVM by below mentioned command:

      nvm ls-remote 
      

      Now choose the version number you want to install from list, Syntax: nvm install [version-number]

      I am going to install version 16.14.0, so replace [version-number] with 16.14.0:

      nvm install 16.14.0 
      

      In general, the latest version is used by nvm, you need to tell nvm to use the version you downloaded by below mentioned command:

      nvm use 16.14.0 
      
    6. Check Version – You can check the version of NodeJs installed using:
      node -v 
      
      Output:
      v16.14.0

      If you are having many node versions installed on your system, to check recently installed version, run the below mentioned command:

      nvm ls 
      
      Output:
      -> v16.14.0 system default -> 16.14.0 (-> v16.14.0) iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v16.14.0) (default) stable -> 16.14 (-> v16.14.0) (default) lts/* -> lts/gallium (-> v16.14.0) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.24.1 (-> N/A) lts/erbium -> v12.22.10 (-> N/A) lts/fermium -> v14.19.0 (-> N/A) lts/gallium -> v16.14.0

    Set Default Version of NodeJs using NVM

    If you want to set any version as default, type the below-mentioned syntax: nvm alias default [version-number]

    I am going to default version v16.14.0 so replace [version-number] with v16.14.0:

    nvm alias default 16.14.0 
    

    Test NodeJs

    We can check whether our installed NodeJs is working or not; make sample JavaScript file using nano command:

    nano sample.js 
    

    The file will be opened in the editor now enter the below-shown content in the file to print “Hello World” on Terminal. Press Ctrl+O to save file and press Ctrl+X to exit file:

    const http = require(‘http’);
    const hostname = ‘localhost’;
    const port = 3000;
    
    const server = http.createServer((req, res) => {
      res.statusCode = 200;
      res.setHeader(‘Content-Type’, ‘text/plain’);
      res.end(‘Hello World\n’);
    });
      server.listen(port, hostname, () => {
      console.log(‘Server running at http://${hostname}:${port}/’);
    });

    Now to start application run below mentioned command:

    node sample.js 
    
    Output:
    Server running at http://localhost:3000

    Run below mentioned command to test application on another terminal:

    curl http://localhost:3000 
    

    How to uninstall NodeJs from Debian 11 Bullseye

    Depending on the version you wish to target, you can remove NodeJs with apt or NVM You will need to deal with the apt program on the system level to uninstall versions installed from the Debian repository or from PPA.
    To uninstall any of version, run the below mentioned command:

    sudo apt remove nodejs 
    

    If you wanted to uninstall version of NodeJs installed from NVM, for that first check the current version of NodeJs installed by below mentioned command:

    nvm current 
    

    Then run the below-mentioned syntax to uninstall any specific version of NodeJs installed using NVM on your system:

    nvm uninstall [version-number]

    I am uninstalling current version of NodeJs, so first I need to deactivate NVM:

    nvm deactivate 
    

    Now run the command:

    nvm uninstall 12.1.0 
    

    Conclusion

    NodeJs is a server-side framework to build JavaScript apps. It is used for both back-end and front-end programming. In this article, we discuss its installation on Debian 11 using three methods which are using Debian’s official Repository, through PPA Repository, and also through NVM and also discuss its testing and uninstallation from the system.

    The post How To Install Node.Js on Debian 11 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/how-to-install-node-js-on-debian-11/feed/ 0
    How To Install Older Version of a NPM Package https://tecadmin.net/install-older-version-npm-package/ https://tecadmin.net/install-older-version-npm-package/#respond Sat, 26 Jun 2021 10:36:25 +0000 https://tecadmin.net/?p=26367 NPM (Node Package Manager) is a command-line tool for managing node modules for Node.js applications. It is used to install, update or delete a node module in your system. It also follows the pacakge.json file for proper management of node modules for an application. The npmjs.com is the centralized repository containing all the node.js modules. [...]

    The post How To Install Older Version of a NPM Package appeared first on TecAdmin.

    ]]>
    NPM (Node Package Manager) is a command-line tool for managing node modules for Node.js applications. It is used to install, update or delete a node module in your system. It also follows the pacakge.json file for proper management of node modules for an application.

    The npmjs.com is the centralized repository containing all the node.js modules. Npm download the packages from npmjs and install them on a client machine. By default, NPM installs the latest version of an available module, but sometimes you may be required an older version of the module for your application.

    This tutorial helps you for installing the old version of modules with NPM command-line tool.

    Syntax

    The npm specific version installation uses the following syntax:

    npm install [packagename]@[version]
    

    Here pacakgename is the name of the packages and version is the version number to be install.

    Installing Specific Version Node Module

    The default NPM installs the latest version of the package. But you can specify the version number to install the specific version of a Node.js package.

    For example, to install the cowsay package with version 1.1.0, type:

    npm install cowsay@1.1.0 
    
    Installing Specific Version Node Module
    Installing Specific Version Node Module

    Similarly, you can install any node modules with the specific version, but the condition is that all the required dependencies are available on the module.

    Search Available Package Version’s with NPM

    Use the following command to find out all the available versions for a Node.js module. This will show you all the versions from the first version to the current version of the module.

    npm view cowsay versions 
    

    Output:

    [
      '1.0.0', '1.0.1', '1.0.2',
      '1.0.3', '1.1.0', '1.1.1',
      '1.1.2', '1.1.3', '1.1.4',
      '1.1.5', '1.1.6', '1.1.7',
      '1.1.8', '1.1.9', '1.2.0',
      '1.2.1', '1.3.0', '1.3.1',
      '1.4.0', '1.5.0'
    ]
    

    Conclusion

    This tutorial describes the instructions to install an older version of node.js modules. Alternatively, you can say to install any specific version of node.js modules.

    The post How To Install Older Version of a NPM Package appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-older-version-npm-package/feed/ 0
    How to Install Node.js on Ubuntu 22.10 & 21.10 https://tecadmin.net/install-nodejs-ubuntu-non-lts/ https://tecadmin.net/install-nodejs-ubuntu-non-lts/#comments Wed, 02 Dec 2020 05:25:01 +0000 https://tecadmin.net/?p=23735 Node.js is the popular language for front-end programming. A number of JavaScript frameworks are available for quick-build mobile and web application development. NVM is a Node Version Manager tool. Using the NVM utility, you can install multiple node.js versions on a single system. You can also choose a specific Node version for applications. This tutorial [...]

    The post How to Install Node.js on Ubuntu 22.10 & 21.10 appeared first on TecAdmin.

    ]]>
    Node.js is the popular language for front-end programming. A number of JavaScript frameworks are available for quick-build mobile and web application development.

    NVM is a Node Version Manager tool. Using the NVM utility, you can install multiple node.js versions on a single system. You can also choose a specific Node version for applications.

    This tutorial described how to install node.js on Ubuntu 22.10 and 21.10 systems using NVM.

    Prerequisites

    • A running Ubuntu Linux system with shell access.
    • Log in with a user account to which you need to install node.js.

    Step 1 – Install NVM

    A shell script is available for the installation of nvm on the Ubuntu system. Use the following commands to install curl on your system, then run the nvm installer script.

    Open a terminal on your system and execute:

    sudo apt install curl 
    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 
    

    The script will create the necessary environment variables in the login script of the current user. You can either log out and log in again to load the environment or use the following to load the environment.

    source ~/.profile   
    

    Step 2 – Install Node.js on Ubuntu

    The NVM allows you to install and manage multiple node.js versions for each user account on a Linux system. You can easily switch to the specific version anytime.

    1. To install the latest node.js version, type:
      nvm install node 
      
    2. To install the latest LTS version of node, type:
      nvm install lts  
      
    3. To install a specific version of node, type:
      nvm install 16.4.0  
      

      You can choose any other version to install using the above command.

    The very first version installed becomes the default. New shells will start with the default version of the node (e.g., nvm alias default).

    Step 3 – Other Useful commands

    You can use the following command to list installed versions of the node for the current user.

    nvm ls 
    

    With this command, you can find the available node.js version for the installation.

    nvm ls-remote 
    

    You can also select a different version for the current session. The selected version will be the currently active version for the current shell only.

    nvm use 16.14.0 
    

    To find the default Node version set for the current user, type:

    nvm run default --version 
    

    You can run a Node script with the desired version of node.js using the below command:

    nvm exec 16.14.0 server.js 
    

    Conclusion

    This tutorial described you to install node.js on Ubuntu 22.10, and 21.10 Linux systems using Node Version Manager.

    The post How to Install Node.js on Ubuntu 22.10 & 21.10 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-nodejs-ubuntu-non-lts/feed/ 1
    How to Install Node.js on Windows 10 https://tecadmin.net/install-nodejs-on-windows-10/ https://tecadmin.net/install-nodejs-on-windows-10/#respond Thu, 17 Sep 2020 17:06:43 +0000 https://tecadmin.net/?p=22706 Node.js is an open-source JavaScript runtime environment. It allows to run JavaScript outside a web browser. This tutorial will help you to install Node.js on your Windows system. Installing Node on Windows Following are the steps to install Node on Windows system. Download Node.js Installer You can downlod the Node Windows installer from its official [...]

    The post How to Install Node.js on Windows 10 appeared first on TecAdmin.

    ]]>
    Node.js is an open-source JavaScript runtime environment. It allows to run JavaScript outside a web browser. This tutorial will help you to install Node.js on your Windows system.

    Installing Node on Windows

    Following are the steps to install Node on Windows system.

    1. Download Node.js Installer

      You can downlod the Node Windows installer from its official download page. Download the installer as per your system architecture.

      Download Node.js for Windows

    2. Run Installer

      Once the installed downloaded, double click on installer file to begin the installation process. Click Next to continue installer.

      Install Node on Windows

      Next, accept the terms of license agreement and click next to continue installation.

      Installing nodejs windows

      Complete the rest of the steps of the installation wizard.

      The installer will automatically configure the required environment variables for the node binary to your system..

    Test Node Version

    The above installer do all the required steps to run node on command line interface. You can check the installed node and npm version via command line.

    Open a terminal and type the following commands:

    node -v
    npm -v
    

    Find Node version on Winodws

    Conclusion

    In this tutorial, you have learned to install node on a Windows system.

    The post How to Install Node.js on Windows 10 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-nodejs-on-windows-10/feed/ 0
    How to Install NVM on Fedora 35/34/33 https://tecadmin.net/install-nvm-on-fedora/ https://tecadmin.net/install-nvm-on-fedora/#respond Tue, 08 Sep 2020 14:39:11 +0000 https://tecadmin.net/?p=22594 NVM (Node Version Manager) is a command-line utility for managing multiple active Node.js versions. Sometimes you required to deploy multiple node application with different-2 versions. Nvm will help you here. Why NVM ? NVM has a number of benefits: It allows installation of multiple node versions on single system and easily switch between them Nvm [...]

    The post How to Install NVM on Fedora 35/34/33 appeared first on TecAdmin.

    ]]>
    NVM (Node Version Manager) is a command-line utility for managing multiple active Node.js versions. Sometimes you required to deploy multiple node application with different-2 versions. Nvm will help you here.

    Why NVM ?

    NVM has a number of benefits:

    • It allows installation of multiple node versions on single system and easily switch between them
    • Nvm install all the node version for the current user only. So it will not make any conflict between other system accounts
    • Easier to switch between different downloaded versions of Node.js with ease.

    Installing NVM on Fedora

    A shell script is available for the installation of nvm on Fedora Linux systems. Open a terminal on your system or connect a remote system using SSH. Use the following commands to install curl on your system, then run the nvm installer script.

    sudo dnf install curl  
    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash   
    

    It creates a .nvm directory under the home directory. Where nvm keeps own binary file and all other required files. Then it sets environment in users .bashrc file. You need to load this environment to set required configuration by running the following command:

    source ~/.bashrc
    

    Installing Node with NVM

    Nvm allows to install multiple node versions on your system for the logged in user. You can find all the available Node version for installation by running command:

    nvm ls-remote 
    

    Above command will show you a list of available node versions. Now you can install any node version by typing:

    nvm install 12.8.3 
    

    Just change 12.8.3 with your required version like 11.15.0, 10.11.0, etc.

    It also provided alias for the latest stable node version, LTS version and other previous LTS version.

    nvm install node        ## install latest stable version 
    nvm install lts/*       ## install latest lts version 
    

    You can also use lts/dubnium, lts/carbon etc.

    Working with NVM

    You can use the following command to list installed versions of node for the current user.

    nvm ls 
    

    With this command, you can find the available node.js version for the installation.

    nvm ls-remote 
    

    You can also select a different version for the current session. The selected version will be the currently active version for the current shell only.

    nvm use 12.18.3 
    

    To find the default Node version set for the current user, type:

    nvm run default --version 
    

    You can run a Node script with the desired version of node.js using the below command:

    nvm exec 12.18.3 server.js 
    

    Uninstall Specific Node Version with NVM

    You can remove any unused version by running the following command. Just make sure the version you are removing is not currently active version.

    To remove Node.js 9.9.0, type:

    nvm uninstall 9.9.0 
    

    Conclusion

    This tutorial helped you to install nvm and node on Fedora Linux system. You also learned about basics of nvm command line utility.

    The post How to Install NVM on Fedora 35/34/33 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-nvm-on-fedora/feed/ 0