Programming, error messages and sample code

How to publish an ExpressJS application to your hosting account

Programming, error messages and sample code > Node.js

In this article, I will try to explain the procedures for publishing an ExpressJS APP that was created from Express Generator. If you install express for your existing application, please follow the normal steps.   1. create a folder  
mkdir express-app

cd express-app
2. generate express  
npx express-generator
3. install dependencies  
npm install
4. run app in development mode  
npm start
it will serve the default express engine (Jade) at http://localhost:3000, if it does not open the URL in your local default browser, please manually access it   5. update your application codes, test in local development, make sure there is no error, and prepare to publish   6. exit your localhost server by typing Ctrl + C in CMD   7. create "index.js" file under "express-app" folder   8. copy the content in "express-app/bin/www" to "express-app/index.js"   9. in "index.js" file, change   
var app = require('../app');
to  
var app = require('./app');
10. start your app again to check if there is any problem  
node index.js
11. archive all files under "express-app" folder including "node_modules" to .zip file   12. upload the .zip file to your site through Control Panel > File Manager or FTP, and then unzip it   13. create NodeJS app for the site root folder   14. change web.config file to  
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" />
        </handlers>
        <httpPlatform processPath="node" arguments="index.js" startupTimeLimit="20" startupRetryCount="2" stdoutLogEnabled="false" stdoutLogFile="./log.txt">
            <environmentVariables>
                <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
                <environmentVariable name="NODE_ENV" value="production" />
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>