The customer portal my.neoserv.com has been redesigned. If you notice any issues, please let us know.

Cart (0)
  • Your cart is currently empty.

NEOSERV BLOG

Tips, guides and useful information about domains, hosting, SSL certificates, email, web optimization and online security.

Node.JS in upravitelj paketov npm
Category: Web Hosting
Published:

npm (Node Package Manager) is the default package manager for the Node.js JavaScript runtime and is included as a recommended feature in the Node.js installer. Using npm, you can therefore easily install and manage packages for Node.js applications.

The use of the Node.js programming environment, the npm package manager and dependencies can be used in a variety of situations:

  • As a standalone Node.js application served by a web server and accessible via a web browser. In the case of a standalone Node.js application, cPanel or CloudLinux offers an integrated Node.js virtual environment (read more about How do I create my first Node.js application?).
  • Only as a dependency required by various PHP frameworks such as Laravel. If you want to use Node.js and npm only as a dependency, you don’t need to set up a Node.js virtual environment (standalone application), and you can install the desired version of each application on the hosting package.

Example: installation and use as a dependency only

If you want to use the Laravel PHP framework, you can install and use any version of the node and npm applications as a standalone dependency. See below for how to do this.

1. Download the Node.js version and extend the archive

Download the desired linux-x64 version from the https://nodejs.org/dist/ repository to your hosting package, the easiest way to do this is to use the command below, which extends the tar.gz archive to its own directory.

curl https://nodejs.org/dist/vXX.X.X/node-vXX.X.X-linux-x64.tar.gz | tar xz

Note: Replace the XX.X.X notation in the above code with the actual version you have chosen.

2. Adding shortcuts

To make it easier to access the installed versions of node and npm, create shortcuts in the personal folder ~/bin and ensure that this folder is included in the system path(PATH).

1. Create a ~/bin folder where the shortcuts will be stored:

mkdir -p ~/bin

2. Create shortcuts to node and npm:

ln -s /path/to/dean/node ~/bin/node
ln -s /path/to/default/npm ~/bin/npm

3. Add ~/bin to the system path if it is not already part of the path:

# Add to your PATH if not already there
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

3. Restart the SSH session (logout and login to the terminal)

The node and npm commands will now use the installed versions of the applications each time we start a fresh SSH (bash) session.

We can check the operation of the flash files with the following commands:

node -v
npm -v

These commands should show us the versions of Node.js and npm that have just been installed.

This completes the installation of the Node.js package management tool(npm) and the build tool(build).

We advise you to build the application locally(npm run build), as the process requires a lot of computing resources. Once the local build is complete, upload the final files to the server.

COMMENTS

COMMENT THE POST

(mandatory)
(mandatory, email address will be hidden)
(optional)
Security question that confirms you are a real person.