Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Installing a Node.JS application on cPanel verison 80

Discussion in 'EasyApache' started by Nirjonadda, May 13, 2019.

Tags:
  1. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    I have installed Node.js with yum install ea-nodejs10 but version check are not working.

    Following command not working.

    Code:
    node --version
    
    npm --version
    Also node app run command not working

    Code:
    -bash: /node: No such file or directory
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #1 Nirjonadda, May 13, 2019
    Last edited: May 13, 2019
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    I need Run the script by executing the following at the command line. We want to run this command in a screen or something similar.

    Code:
    node app.js
    So need to use this following the command?

    Code:
    /opt/cpanel/ea-nodejs10/bin/node app.js
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Nirjonadda,

    I recommend installing the application as a cPanel user in order to take advantage of the Application Manager feature and the How to Install A Node.js Application tutorial. Using this approach, you can edit the /home/$username/.bashrc file to export specific paths to the user's environment in order to execute commands such as "npm install" from the application's source directory.

    Are you installing an open source application that's hosted on GitHub? If so, feel free to post the GitHub URL here and I'll provide you with the steps you should take to install it.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    No, I am using Discord Integration for xenforo.

    Allowing the bot to appear online:
    This is a slightly more advanced feature that you'll need to setup yourselves. Eventually, I hope to expand this part of the add-on but until then, here's the run down:
    1. You'll need to install node on your server. Contact your host or sysadmin if you're unsure of how to do this.
    2. Download the add-on's zip file, navigate to the "bot" folder in the zip root and open config.json.
    3. Set the token to the value you copied from your Discord Web API application when you installed the add-on.
    4. Set the status field to anything you want. It'll read "Playing {status}" on your server.
    5. Run the script by executing the following at the command line. You'll want to run this command in a screen or something similar.
    Code:
    node app.js
    folder paths:

    Code:
    /public_html/src/addons/NF/Discord/_extra/bot/app.js
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Nirjonadda,

    You can complete the following steps to install that application:

    1. Log in to the server via SSH as the cPanel user.
    2. Create the application's directory, relative to your home directory. EX:

    Code:
    mkdir /home/$username/nodejsapp
    3. Upload the application's .zip file to /home/$username/nodejsapp and unzip it within this directory. EX:

    Code:
    cd /home/$username/nodejsapp
    unzip $application-name.zip
    4. Browse to the extracted "bot" sub-directory and edit the config.json file per that addon's instructions.
    5. From the "bot" sub-directory, complete steps 2-4 on the previously linked tutorial.

    Let me know if you encounter any trouble with these instructions.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Not working Test the application.

    Code:
    [nadda@na ~]$ /opt/cpanel/ea-nodejs10/bin/node app.js
    internal/modules/cjs/loader.js:583
        throw err;
        ^
    
    Error: Cannot find module '/home/nadda/app.js'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
        at Function.Module._load (internal/modules/cjs/loader.js:507:25)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:283:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
    [nadda@na ~]$ curl http://127.0.0.1:3000
    curl: (7) Failed connect to 127.0.0.1:3000; Connection refused
    [nadda@na ~]$
    or

    Code:
    [nadda@na ~]$ /opt/cpanel/ea-nodejs10/bin/node /home/nadda/nodejsapp/discord_bot/app.js
    Aborted (core dumped)
    [nadda@na ~]$
    How to Register the application? What need add for Application URL and Path?

    ScreenShot01103.png
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Get this with step 1 Install the application.

    Code:
    [nadda@na ~]$ /opt/cpanel/ea-nodejs10/bin/node /home/nadda/nodejsapp/app.js
    node[110]: pthread_create: Resource temporarily unavailable
    Server running at http://127.0.0.1:3000/
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    You must browse to the directory where app.js exists before running the above command.

    Can you try installing the test application provided in the example on the How To Install A Node.JS Application tutorial first and verify it works properly? This will help us rule out whether there's a global issue or an issue specific to your application.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Yes but only working in /home/$username/public_html directory, not work in /home/$username/ directory. App run closed when close the web browser tab. So how can made app running all time?

    Issue are same, this from test application provided in the example.

    Code:
    [nadda@na ~]$ /opt/cpanel/ea-nodejs10/bin/node /home/nadda/nodejsapp/app.js
    node[110]: pthread_create: Resource temporarily unavailable
    Server running at http://127.0.0.1:3000/
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    I'm unable to reproduce this error message when installing the example Node.js application per the documented instructions. Can you open a support ticket so we can take a closer look at your system to see what's leading to this error message?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    OK But please can you let me know about only working in /home/$username/public_html directory, not work in /home/$username/ directory. App run closed when close the web browser tab. So how can made app running all time?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Nirjonadda,

    A couple of points:

    1. You can use cPanel >> Application Manager to enable the application:

    Application Manager - Version 78 Documentation - cPanel Documentation

    2. If you want your application to automatically restart upon modification, create an empty file named restart.txt within the application's tmp directory (e.g. /home/username/nodejsapp/tmp/restart.txt). The restart.txt file directs Mod_Passenger to restart the application automatically after it's modified. You must create the empty restart.txt file each time that you want Mod_Passenger to restart the application.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Yes enabled but the application are not continues to run after closing shell session or web browser tab.

    ScreenShot01106.png

    ScreenShot01107.png

    Also showing this error:

    ScreenShot01108.png
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Can you proceed to open a support ticket so we can take a closer look at your system to see the error in action? You can post the ticket number here and we'll link this thread to it.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Nirjonadda

    Nirjonadda Well-Known Member

    Joined:
    May 8, 2013
    Messages:
    644
    Likes Received:
    16
    Trophy Points:
    68
    cPanel Access Level:
    Root Administrator
    Support Request ID is: 12316397
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    cPanelMichael likes this.
  17. Tarak Nath

    Tarak Nath Well-Known Member

    Joined:
    Mar 12, 2018
    Messages:
    73
    Likes Received:
    11
    Trophy Points:
    8
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    Is the issue resolved ? We are also going to work with Nodejs.

    Please update.
     
  18. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,272
    Likes Received:
    2,154
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    To update, the issue reported as part of ticket 12316397 was caused by custom redirect rules added to the /home/username/public_html/.htaccess file preventing the application URL from loading in the web browser.

    @Tarak Nath Let me know of any specific issues you encounter when installing NodeJS applications.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice