NPM or Node Package Manager is the same thing as APT to Debian. It is used to install, remove, update NodeJS packages. In this article, I will show you how to install and use NPM on Debian 9 Stretch.
In this tutorial we will show you how to install Steam on Debian 9 Stretch. For those of you who didn’t know, Steam is a digital distribution platform for video games. As Amazon Kindle is digital distribution platform for e-Books, iTunes for music, similarly Steam is for games. How to Install and Use NPM on Debian 9 Stretch. NPM or Node Package Manager is the same thing as APT to Debian. It is used to install, remove, update NodeJS packages. In this article, I will show you how to install and use NPM on Debian 9 Stretch. Installing NodeJS and NPM.
Installing NodeJS and NPM
The version of NodeJS available in the official Debian 9 Stretch package repository is 4.x, which is very old. The official package repository of Debian 9 Stretch does not have NPM. In this section, I will install the latest stable version of NodeJS and NPM which is at the time of this writing 8.11.1.
First update the apt package repository cache with the following command:
Now install CURL with the following command:
Press y and then press <Enter> to continue.
CURL should be installed.
![Debian Debian](/uploads/1/2/6/3/126348531/288978229.webp)
Now add the package repository of NodeJS 8.x with the following command:
$ curl -sL https://deb.nodesource.com/setup_8.x |sudo-Ebash -
The NodeJS 8.x package repository should be added as you can see from the screenshot below.
Now you can install NodeJS and NPM all together along with the development tools for building native NodeJS modules with the following command:
Now press y and then press <Enter> to continue.
NodeJS, NPM and the required build tools for compiling NodeJS native modules are installed.
Now check whether NodeJS is working with the following command:
As you can see, NodeJS 8.11.1 is installed and working correctly.
Now check whether NPM is working with the following command:
As you can see NPM is installed correctly as well.
Using NPM
In this section, I will show you how to use NPM to manager NodeJS modules or packages. Before that, let’s talk about global packages and local packages.
If you install a NodeJS package globally, then it should be saved somewhere /usr/lib/node_modules directory and you can access it from any NodeJS project.
If you install a NodeJS package locally, then a directory node_modules/ should be created on your project directory and the package should be saved in node_modules/ directory relative to your project directory. It can only be accessed from that project.
That’s all you need to know for now. Let’s continue.
Creating a package.json Configuration File with NPM:
Every NodeJS project has a package.json file in its project’s root directory. This file holds information about your project, such as the name of the project, the version of the project, the dependencies or other NodeJS packages your project depends on and many more. You can manually create a package.json file and put all these information or you can use NPM to create it for you.
First create a new directory node-project (you can name is whatever you want) for your NodeJS project with the following command:
Now navigate to your project directory with the following command:
Now to create a package.json file with NPM, run the following command:
Fill in the details and press <Enter> to move forward.
In the end, type in yes and press <Enter>.
As you can see, a package.json file is created.
This is the contents of the package.json file:
Installing a NodeJS Package Locally with NPM:
If you know the name of the package, then you can easily install it using NPM.
For example, if you want to install expressNodeJS package, which is Express web framework, run the following command from your project directory:
expressNodeJS package should be installed.
Installing a NodeJS Package Globally with NPM:
You can install a NodeJS package globally from any directory. For example, if you want to install expressNodeJS package globally, run the following command:
![Ubuntu Ubuntu](/uploads/1/2/6/3/126348531/435337776.png)
It should be installed globally.
Removing a NodeJS Package Locally with NPM:
If you want to remove a NodeJS package, let’s say express, from your project directory, run the following command from your project directory:
The express NodeJS package is removed.
Removing a NodeJS Package Globally with NPM:
To remove a NodeJS package, let’s say express, globally, run the following command:
It should be removed.
Searching for NodeJS Packages:
Well, now you know how to install and remove NodeJS packages with NPM. Now the question is, how do I know what I can install with NPM? What packages are available?
Well, you can search for packages in the NPM’s official website at https://www.npmjs.com/ or you can use NPM command line utility.
To search for NodeJS packages from your web browser, go to https://www.npmjs.com/ and search for what you’re looking for. Type in the keywords as marked in the screenshot below, and press <Enter>.
You should see a lot of packages as you can see in the marked section of the screenshot below. You can click on any one of them to see more information about that package.
You can also run the following command to search for NPM packages:
As you can see, the same list is displayed. You can pick up the package name from the first column as marked in the screenshot below, and install what you need using NPM.
So that’s how you install and use NPM on Debian 9 Stretch. Thanks for reading this article.
I have some problems with installation of Debian 9 HVM guest in xenserver 7.3 throug XenCenter (7.3.0.5783).
I have noticed that the option to install the guest os with 'install from URL' has been removed from Debian template version 8 and 9 (this are HVM templates).
In the template for Debian 7 (PV) there is still the option to install from URL.
I know its still possible to install debian 8 and 9 from 'install URL' in reference to: Citrix xenserver 7.3 Virtual machine user guide https://docs.citrix.com/content/dam/docs/en-us/xenserver/current-release/downloads/xenserver-vm-users-guide.pdf on page 19. In the manual its only described how to do this by CLI with command '
xe vm-param-set uuid=<UUID> other-config:install-repository=<path_to_repository>' where the path is debians repository.
As you can see from image: debian_9_install_option.jpg. There is no way to specify the install URL methode in the VM creation procedure for template debian 8 and 9 (HVM)
and in image: debian_9_missing_url.jpg the summary of the VMs creation specifications the 'Install URL' parameter is empty.
My thought around this is that the problem is in xencenter that the parameter and the respective commands are just simply missing from this version of Xencenter.
This gave me an Idea to clone the Debian stretch template and set the 'install URL' as a default parameter in the cloned template, i have constructed this script:
Is this a OK methode of doing this? iam not so keen to use CLI to install all this VMs i need with Debian, and i dont want to do it with ISO library.
In the future the default Debian Stretch 9.0 template should have the possibility to set the install URL inside XenCenter upon VM creation as the Debian 7.0 Wheezy template has today.
I hope its possible to get any feedback on this, all help is much appreciated.
Best regards
Raymond Paulsen