Nodejs on cpanel problems and how to fix them

I have been messing around for 3 days trying to get my node.js app to work on my remote hosting using WHM/cPanel.
After @Teodor gave us that Plesk tutorial today, I realised that I have actually been doing it correctly from the start and it really should have been working all along.

Well I finally figured out what the issue is, and it turns out I just should have read the node docs a little better.
This is what they say
Screenshot 2020-05-29 at 16.38.59

Wappler has an index.js file and not an app.js file so the passenger script is basically just ignoring the entire app. I have duplicated the index.js file from Wappler and added a second file called app.js, and finally I have a working page.

@George, could index.js be changed to app.js without harming the inner workings or is this going to cause other issues for me as I go.

If when using application manager in your cpanel you get this error


You may need an additional file placed in the root of your cpanel account, so in my case /home/paul called .npmrc and the file contents has this one line in it.

scripts-prepend-node-path=true

Save your file and try run the Ensure dependencies command again and the error should go away, thank you Teo, I would never have figured that one out.

1 Like

Yes you can safely rename the index.js to app.js and add .npmrc

1 Like

I don’t understand, does it still need to be done in Wappler beta 3 ?

If you want to run through the node.js server inside a cPanel environment then yes, in wappler 3 beta 3 running through the passenger ruby module for apache you will have to alter index.js and rename it app.js or the module will not run it.
Check the wappler doc on running your node.js app through plesk or cPanel for the full details.