[Vuejs]-Vue Node.js/express app error cannot set property render of undefined

0👍

You are missing

app.get('*', function(req, res) {
  res.sendFile(path.join( __dirname, './index.html')); //path to index.html
});

your new code be like

const express = require('express');
const path = require('path');
const serveStatic = require('serve-static');

let app = express();
app.use(serveStatic(__dirname + "/dist"));

const port = process.env.PORT || 5000;
  app.get('*', function(req, res) {
      res.sendFile(path.join( __dirname, './index.html')); //path to index.html
    });


app.listen(port, () => {
  console.log('Listening on port ' + port)
});

Leave a comment