Under development mode, the NodeJS app is run via SSH. The port on which your App should run should be in the range of ports made available to the SSH user. To run the app in development mode
- Login into the N99panel
- Go to under Dashboard -> Node Apps -> Link a Node App
- Select the VHost (website) mentioned along with the user and the port range. If under the port range it shows ‘Requires user rebuild’, rebuild the user from Dashboard -> List Users -> Rebuild (for the desired user) and click ‘Rebuild User’. After rebuilding the user, revert to the ‘Link a Node App’ page.
- Enter the ‘App Web path’ . This would be like /app1 or /app2 or it can even be the website root i.e. /
- Enter the ‘App Port’ . The port entered under should be within the range of the port numbers mentioned in point 3.
- Select the ‘App Mode’. This should be ‘Development’
- And finally click ‘Submit’
With the above steps, you have mapped the web-server to the VHost/Website’s URL part and the port number where we can expect the NodeJS App to be running.
N99panel comes with multiple NodeJS versions i.e. 10, 12, 14, 16, 18, 20. These versions can be referenced from within SSH using the commands node10 , node12 , node14, node16, node18, node20 respectively. The npm’s accompanying these versions can be referenced via npm10 , npm12 , npm14, npm16, npm18, npm20 respectively.
Now to run the App,
- Login into the server/VPS via SSH of the user ID under which the VHost/website is running.
- Though you can run the NodeJS App from any folder, but ideally create a new App folder within the node_apps folder. This would help later also when we shift this App to the Production mode.
- Now assuming that you created a app folder app1 , now under that folder upload all your source files including package.json
- Lets’s say that we wish to user version 16 , to run NPM commands w.r.t. that ideally we will use npm16 .
- To run the app, we should first ensure that the NodeJS source file creates the Node server at ‘App Port’ number. We’ll explain further via example
- Let’s say the user port range is 50001 to 50010 , and the port we entered under ‘App Port’ is 50001
- Now my app file is say app.js . In my app.js I would need to create the server on port 50001 .
- To now actually run the app, we just need to type
node16 app.js &
Above process would now start the App as a background process. If there are errors, it will simply show the errors and the process would end. And when you fix the errors, you can again try starting the App.
When you believe that you app is running stably and as per your expectations, at that moment you can decide to shift your App to the Production mode. Click here to read about it.