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
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
14. change web.config file to
<configuration>
<system.webServer>
<!-- indicates that the index.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
</handlers>
<!-- fallback all requests to index.js -->
<rewrite>
<rules>
<rule name="mysite">
<match url="/*" />
<action type="Rewrite" url="index.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Article ID: 2228, Created: August 24, 2022 at 6:20 AM, Modified: August 24, 2022 at 6:23 AM