I'm trying to get a Node.js server and project online on cPanel

I’m trying to get a Node.js server and project online again.
However, my CPanel interface does not show all options as in the tutorial.
For example, I can’t specify the “Document Root”.

I followed the tutorial to the best of my knowledge.

As you can see, we see nothing…

What am I doing wrong?

Thank you for your help

I’m a PLESK user so not familiar with CPanel, however you should be able to set your Document Root from the web hosting settings for the site and not the NodeJs settings section.

Alright, thanks for the tip.
I have now adapted the document root directly in the subdomain settings.

But now I only get that displayed.

Could you revert that last change please? I disagree with that change, better to get back to how you were

I see in your FileZilla screenshot a file named stderr.log, it should contain an error message there

I reset the document root.
then the file “stderr.log” is created.
Here’s what’s inside.

/iscsi3/secret/node.secret.de/app/lib/setup/config.js:72

if (typeof config.cors?.origin == 'string') {

^

SyntaxError: Unexpected token '.'

at wrapSafe (internal/modules/cjs/loader.js:915:16)

at Module._compile (internal/modules/cjs/loader.js:963:27)

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

at Module.load (internal/modules/cjs/loader.js:863:32)

at Function.Module._load (internal/modules/cjs/loader.js:708:14)

at Module.require (internal/modules/cjs/loader.js:887:19)

at require (internal/modules/cjs/helpers.js:74:18)

at Object.<anonymous> (/iscsi3/secret/node.secret.de/app/lib/server.js:10:16)

    at Module._compile (internal/modules/cjs/loader.js:999:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

    /iscsi3/secret/node.secret.de/app/lib/setup/config.js:72

    if (typeof config.cors?.origin == 'string') {

    ^

    SyntaxError: Unexpected token '.'

    at wrapSafe (internal/modules/cjs/loader.js:915:16)

    at Module._compile (internal/modules/cjs/loader.js:963:27)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

    at Module.load (internal/modules/cjs/loader.js:863:32)

    at Function.Module._load (internal/modules/cjs/loader.js:708:14)

    at Module.require (internal/modules/cjs/loader.js:887:19)

    at require (internal/modules/cjs/helpers.js:74:18)

    at Object.<anonymous> (/iscsi3/secret/node.secret.de/app/lib/server.js:10:16)

        at Module._compile (internal/modules/cjs/loader.js:999:30)

        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

        /iscsi3/secret/node.secret.de/app/lib/setup/config.js:72

        if (typeof config.cors?.origin == 'string') {

        ^

        SyntaxError: Unexpected token '.'

        at wrapSafe (internal/modules/cjs/loader.js:915:16)

        at Module._compile (internal/modules/cjs/loader.js:963:27)

        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

        at Module.load (internal/modules/cjs/loader.js:863:32)

        at Function.Module._load (internal/modules/cjs/loader.js:708:14)

        at Module.require (internal/modules/cjs/loader.js:887:19)

        at require (internal/modules/cjs/helpers.js:74:18)

        at Object.<anonymous> (/iscsi3/secret/node.secret.de/app/lib/server.js:10:16)

            at Module._compile (internal/modules/cjs/loader.js:999:30)

            at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

            /iscsi3/secret/node.secret.de/app/lib/setup/config.js:72

            if (typeof config.cors?.origin == 'string') {

            ^

            SyntaxError: Unexpected token '.'

            at wrapSafe (internal/modules/cjs/loader.js:915:16)

            at Module._compile (internal/modules/cjs/loader.js:963:27)

            at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

            at Module.load (internal/modules/cjs/loader.js:863:32)

            at Function.Module._load (internal/modules/cjs/loader.js:708:14)

            at Module.require (internal/modules/cjs/loader.js:887:19)

            at require (internal/modules/cjs/helpers.js:74:18)

            at Object.<anonymous> (/iscsi3/secret/node.secret.de/app/lib/server.js:10:16)

                at Module._compile (internal/modules/cjs/loader.js:999:30)

                at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

The problem is your NodeJS version is too old, you’re running NodeJS 12. Can you maybe update to 16 or higher? (18, 20, …)

Hi Christian
I use node on VPS all the time so lets work through this in stages

  1. Node version outdated.
    Yes, node 16 is desirable although i have only come across one issue with older version but i do recommend upgrade

Assuming you are running Node via mod passenger on cPanel you should have an option to upgrade to node 16 in cPanel under Apache4 -> Additional packages like this

  1. I don’t think specifying document root is actually an issue

You need to set the Base URL (your domain) and the node folder

Running a node server means basically the server runs your node application (index.js or in some cPanel instances it needs to be renamed app.js)
From there, settings are configured by the various JSON config files within the app, not the server

You set your document root set via wappler here


The actual name of the Remote directory is simply a personal choice, i use “nodejsapp” but that’s my choice. You will have to create that folder on your server with file manager as Wappler will not create it for you.

From that point all roots are relative, set within you app JSON config files of Wappler

You need to have the node application running in the application manager to make things work.

Here is how it becomes a little complicated, to have the app running you need the NODE files present on the server so you need to upload the site using publish to the server first

WARNING,“Test” in the project panel will fail as the NODE files are not present and the app is not running, just upload anyway, the files should upload if your FTP settings are correct as FTP is in no way NODE dependent. you should see the uplaod in the “Output” panel

Having uploaded the node support files you should then be able to add the setting to the application manager as above and the app should run. If the application is running correctly you will see the “Ensure Dependencies” message.

Wappler will manage the default folders for you with /app/public being the public root and the .ejs files in the app root.

Hope that helps, happy to answer questions

2 Likes

After a server update I now have the node version on 18 and it works… :smiley:
Many thanks so far. :+1:

Now the question arises whether there is a possibility to transvert my mysql data into the sqlite database?

sqlite is a good option for local development and local dev environment set up. On your remote/live server you can use mysql.

Database version problem

Hello again.
I have the Nodejs page online now, but there is a database problem.
I get this message on my local server:

{status: "500", code: "ER_NOT_SUPPORTED_AUTH_MODE",…}
code
: 
"ER_NOT_SUPPORTED_AUTH_MODE"
message
: 
"ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client"
stack
: 
"Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client\n    at Handshake.Sequence._packetToError (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\sequences\\Sequence.js:47:14)\n    at Handshake.ErrorPacket (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\sequences\\Handshake.js:123:18)\n    at Protocol._parsePacket (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:291:23)\n    at Parser._parsePacket (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Parser.js:433:10)\n    at Parser.write (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Parser.js:43:10)\n    at Protocol.write (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:38:16)\n    at Socket.<anonymous> (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\Connection.js:88:28)\n    at Socket.<anonymous> (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\Connection.js:526:10)\n    at Socket.emit (node:events:390:28)\n    at addChunk (node:internal/streams/readable:315:12)\n    --------------------\n    at Protocol._enqueue (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:144:48)\n    at Protocol.handshake (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\protocol\\Protocol.js:51:23)\n    at Connection.connect (C:\\server\\www\\nodetest\\node_modules\\mysql\\lib\\Connection.js:116:18)\n    at C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql\\index.js:66:18\n    at new Promise (<anonymous>)\n    at Client_MySQL.acquireRawConnection (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\dialects\\mysql\\index.js:61:12)\n    at create (C:\\server\\www\\nodetest\\node_modules\\knex\\lib\\client.js:262:39)"
status
: 
"500"

This message on my online server::
{status: “500”,…}

message

:

"Knex: run\n$ npm install mysql --save\nCannot find module 'mysql'\nRequire stack:\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/dialects/index.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/internal/config-resolver.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/Knex.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/index.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/knex.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/core/db.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/core/app.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/core/middleware.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/setup/routes.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/server.js\n- /home/mydomain/domains/mydomain/public_html/app/index.js\n- /usr/local/lsws/fcgi-bin/lsnode.js"

stack

:

"Error: Knex: run\n$ npm install mysql --save\nCannot find module 'mysql'\nRequire stack:\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/dialects/index.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/internal/config-resolver.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/Knex.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/index.js\n- /home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/knex.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/core/db.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/core/app.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/core/middleware.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/setup/routes.js\n- /home/mydomain/domains/mydomain/public_html/app/lib/server.js\n- /home/mydomain/domains/mydomain/public_html/app/index.js\n- /usr/local/lsws/fcgi-bin/lsnode.js\n at Client_MySQL.initializeDriver (/home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/client.js:202:13)\n at new Client (/home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/client.js:83:12)\n at new Client_MySQL (/home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/dialects/mysql/index.js:21:1)\n at knex (/home/mydomain/nodevenv/domains/mydomain/public_html/app/18/lib/node_modules/knex/lib/knex-builder/Knex.js:16:28)\n at App.setDbConnection (/home/mydomain/domains/mydomain/public_html/app/lib/core/app.js:406:27)\n at App.getDbConnection (/home/mydomain/domains/mydomain/public_html/app/lib/core/app.js:425:25)\n at App.select (/home/mydomain/domains/mydomain/public_html/app/lib/modules/dbconnector.js:15:25)\n at App._exec (/home/mydomain/domains/mydomain/public_html/app/lib/core/app.js:610:57)\n at App.exec (/home/mydomain/domains/mydomain/public_html/app/lib/core/app.js:546:20)\n at App.define (/home/mydomain/domains/mydomain/public_html/app/lib/core/app.js:528:20)"

status

:

"500"

What am I doing wrong? Thank you for your help!