NodeJs/Express Vue CLI3 app Error cannot set property render of undefined

Viewed 922

I am new to NodeJs, its been three days as I am trying to run a Vue app in production mode by Express, for some reason its not going through, I have a Vue CLI3 setup with bootstrap 4. when I run the application in the development mode using npm run serve, it gets rendered perfectly fine. but it doesn't get rendered when i try to run it using a server.js file below is my server.js code

const express = require('express');

const port = process.env.PORT || 5000;

let app = express();



app.use(express.static(__dirname + "/dist/"));

app.get("*", (req, res) => {
    res.sendfile(__dirname + '/dist/index.html');
   
  });

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

I even replaced the res.sendfile(__dirname + '/dist/index.html'); with res.send({response message}) to get the message rendered in the browser, but it logs the same errors to the console.

-this is a screenshot of my package.json file enter image description here

this is the main.js file enter image description here

and these are the errors i am getting the consoleenter image description here

agian the app is working perfectly when running it using npm run serve. does anybody have any idea what is going on here ?!!

1 Answers
Related