I am trying to make an Electron 5 app using Angular 8. I've followed several tutorials online and I'm still getting the same error.
I already created a new project, ran ng serve --open
and it worked fine, I got the default angular home page.
I then installed electron with npm install --save-dev electron
. I created my main.js
file in the root directory of the project and put:
const { app, BrowserWindow } = require('electron')
let win;
function createWindow() {
// Create the browser window.
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('dist/myproject/index.html')
// Open the DevTools.
win.webContents.openDevTools()
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
I also changed the <base href="/">
to <base href="./">
in index.html
.
I modified the package.json
file accordingly as well:
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "ng build && electron ."
},
The issue I'm getting when running npm run electron
is a white screen with these errors:
runtime-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
styles-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
main-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
polyfills-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
vendor-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
I am trying to make an Electron 5 app using Angular 8. I've followed several tutorials online and I'm still getting the same error.
I already created a new project, ran ng serve --open
and it worked fine, I got the default angular home page.
I then installed electron with npm install --save-dev electron
. I created my main.js
file in the root directory of the project and put:
const { app, BrowserWindow } = require('electron')
let win;
function createWindow() {
// Create the browser window.
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('dist/myproject/index.html')
// Open the DevTools.
win.webContents.openDevTools()
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
I also changed the <base href="/">
to <base href="./">
in index.html
.
I modified the package.json
file accordingly as well:
"main": "main.js",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron": "ng build && electron ."
},
The issue I'm getting when running npm run electron
is a white screen with these errors:
runtime-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
styles-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
main-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
polyfills-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
vendor-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
Share
Improve this question
asked Jul 29, 2019 at 21:10
Marwan NMarwan N
5316 silver badges21 bronze badges
1 Answer
Reset to default 7Angular builds in both es5
and es2015
, Electron might not like the indecision. Does your tsconfig.json
have the proper target:
"target": "es5"