2

I want to make a desktop app using Electron.js and Express.js

when it was first loaded i got a warning like this:

SyntaxError: Unexpected token < in JSON at position 0", source: devtools://devtools/bundled/shell.js

Is there something wrong with my code ?

and in developer console has a warning like this:

WARNING

Server.js

import express from 'express';
import bodyParser from 'body-parser';
import path from 'path';
import cors from 'cors'
const app = express();
const PORT = process.env.PORT || 5000;

(function(){
    app.use(cors())
    app.use(express.static('public'));

    app.get('*', (req, res) => {
        res.sendFile(path.resolve(__dirname, '../public/index.html'));
    })

    app.listen(PORT, (err) => {
        if (err) {
            console.log(err)
        } else {
            console.log(`Server is Running on PORT : ${PORT}`)
        }
    })
})();

Electron

const electron = require('electron');
const server = require('./server')
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
const url = require('url');
let mainWindow;

function createWindow() {
    mainWindow = new BrowserWindow({ width: 800, height: 600 });
    mainWindow.loadURL('http://localhost:5000');
    mainWindow.webContents.openDevTools();
    mainWindow.on('closed', function () {
        mainWindow = null
    })
}
app.on('ready', createWindow);
app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') {
        app.quit()
    }
});

app.on('activate', function () {
    if (mainWindow === null) {
        createWindow()
    }
});
Faris Dewantoro
  • 1,597
  • 4
  • 17
  • 31
  • Possible duplicate of [ESRI : Failed to parse source map](https://stackoverflow.com/questions/36051891/esri-failed-to-parse-source-map) – spring Sep 01 '19 at 16:18
  • It is often helpful to search on the error message to see if others have encountered the same error. For example: https://stackoverflow.com/questions/36051891/esri-failed-to-parse-source-map – spring Sep 01 '19 at 16:19

1 Answers1

0

Try to use quick start app officially provided in the electron website

Direct github url is provided in the link

Otherwise download demo apps from officially provided in the electron demo apps

Dickens A S
  • 3,824
  • 2
  • 22
  • 45