Swilam Muhammad
Swilam Muhammad

Reputation: 133

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

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 ?!!

Upvotes: 2

Views: 935

Answers (1)

kmek
kmek

Reputation: 1256

Check to see if you have any components with empty <script> tags. Simply remove those empty tags. This solved the issue for me

https://github.com/vuejs/vue-cli/issues/2430

Upvotes: 3

Related Questions