How to Use Node Modules on Cloudways
Emmad avatar
Written by Emmad
Updated over a week ago

Table of Contents

This guide will assist you in the process of using the Node module on Cloudways. We are going to use angular@cli. All the node modules that you will install on Cloudways will be installed locally in your application. You could set the relevant path in your server for allowing you to install node modules in the application. You can install these modules in your public_html directory.

First, we set the path and configure the npm_config in the application folder. Read here to learn how to connect with SSH via master credentials.

How to Use Node Modules

Step #1

  • Login to your server and run these commands:

1: cd && echo "export PATH='$PATH:/home/master/bin/npm'" >> .bash_aliases

2: cd ~ && echo "export NODE_PATH='$NODE_PATH:/home/master/bin/npm/lib/node_modules'" >> .bash_aliases

3: npm config set prefix "/home/master/bin/npm/lib/node_modules"

These commands are necessary for any node module you want to install in your application. Otherwise if you run npm commands without setting path, it will give you Permission denied errors

Step #2

Choose the application, go into its public_html directory:

cd applications/<application_name>/public_html

To install angular@cli locally, run the following command:

1: npm install @angular/cli

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?