Answer the question
In order to leave comments, you need to log in
Import in nodejs 10.11.0 - how to make it work?
import app from 'electron';
import BrowserWindow from 'electron';
app.on('ready', () => {
createWindow();
});
app.on('window-all-closed', function() {
app.quit();
});
function createWindow() {
let appWindow = new BrowserWindow({
width: 800,
height: 600,
devTools:true,
});
appWindow.loadURL(path.join(__dirname, 'App/index.html'));
return appWindow;
};
Answer the question
In order to leave comments, you need to log in
It's best to use https://babeljs.io/ and not worry about what is for the backend and what is for the frontend. Firstly, you don’t have to change anything (such as an extension for using mjs), on the other hand, now it is the de facto standard in the js world, and thirdly, there is no way at all in the front without it.
As stated in the documentation - ES6 imports only work in files with the .mjs extension when the --experimental-modules flag is enabled.
The reasons for this behavior are well written in an article from one of the node.js developers
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question