Netlify does not make it easy to host an Express web app. I hope you will find this guide useful.
The package.json can look like this:
"scripts": { "start": "node ./functions/server.js", "build": "netlify deploy --prod", "build-dev": "NODE_ENV=development webpack --mode development --watch", "dev": "NODE_ENV=development node server-local.js", "dev-watch": "NODE_ENV=development nodemon --exec node server-local.js", },
Write your server.mjs code such as the image:
[functions] included_files = [ "static/views/**" # Include all files in static/views for server-side access ]
[build] publish = "static" # Static assets to be served by Netlify's CDN. Folder defaults to public
The above is the detailed content of How to deploy a Node.js Express app on Netlify (4). For more information, please follow other related articles on the PHP Chinese website!