The same code was running on Windows and OSX.
But it randomly stopped working on Windows 10
error is:
import { app, BrowserWindow } from 'electron';
^^^
SyntaxError: Unexpected token import
screenshot of the error is:

I do not have a testcase as such. it randomly stopped working
but the sample app is at https://github.com/deepak/electron-webview-todo/
i am using Powershell ISC on Windows 10 for running npm start
electron-forge with the environment variable DEBUG=electron-forge:*.PS C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo> npm start
> [email protected] start C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo
> cross-env DEBUG=electron-forge:* electron-forge start --enable-logging
npm : WARNING: DEBUG environment variable detected.ββProgress indicators will be sent over electron-forge:lifecycle
At line:1 char:1
+ npm start
+ ~~~~~~~~~
ββββ+ CategoryInfoββββββββββ: NotSpecified: (WARNING: DEBUG ...forge:lifecycle:String) [], RemoteException
ββββ+ FullyQualifiedErrorId : NativeCommandError
Fri, 20 Jan 2017 10:39:29 GMT electron-forge:lifecycle Process Started: Checking your system
Fri, 20 Jan 2017 10:39:29 GMT electron-forge:lifecycle Process Succeeded: Checking your system
Fri, 20 Jan 2017 10:39:29 GMT electron-forge:runtime-config setting key: verbose to value: false
WARNING: DEBUG environment variable detected.ββProgress indicators will be sent over electron-forge:lifecycle
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:lifecycle Process Started: Locating Application
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:project-resolver searching for project in:
C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:project-resolver electron-forge compatible package.json found in
C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\package.json
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:lifecycle Process Succeeded: Locating Application
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:lifecycle Process Started: Preparing native dependencies
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:lifecycle Process Succeeded: Preparing native dependencies
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:lifecycle Process Started: Launching Application
Fri, 20 Jan 2017 10:39:31 GMT electron-forge:lifecycle Process Succeeded: Launching Application
App threw an error during load
C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\src\main-process\main.js:5
import { app, BrowserWindow } from 'electron';
^^^^^^
SyntaxError: Unexpected token import
ββββat Object.exports.runInThisContext (vm.js:76:16)
ββββat Module._compile (module.js:528:28)
ββββat Object.Module._extensions..js (module.js:565:10)
ββββat Module.load (module.js:473:32)
ββββat tryModuleLoad (module.js:432:12)
ββββat Function.Module._load (module.js:424:3)
ββββat loadApplicationPackage (C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\node_module
s\electron\dist\resources\default_app.asar\main.js:280:12)
ββββat Object.<anonymous> (C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo\node_modules\el
ectron\dist\resources\default_app.asar\main.js:322:5)
ββββat Module._compile (module.js:556:32)
ββββat Object.Module._extensions..js (module.js:565:10)
command to start Elecron is:
cross-env DEBUG=* electron-forge start --enable-logging
config.forge data in package.json look like?{
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {},
"electronWinstallerConfig": {
"name": "electron-webview-todo"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {},
"github_repository": {
"owner": "",
"name": ""
}
}
}
But it randomly stopped working on Windows 10
Nothing happens randomly, you probably deleted the .compilerc by accident or corrupted your node_modules directory or something similar. On a fresh clone your repository I do not encounter this error so I can only assume that something has broken in your local.
Perhaps one of the issues mentioned above, perhaps not. You should try resetting your local dev environment.
Nothing happens randomly, you probably deleted the .compilerc by accident
I do not know even where the .compilerc file is. so am assuming did not delete it
where is the .compilerc file on windows and OSX ?
By random, i meant that it was working before and then stopped working
Can i request a electro-forge doctor command to check the dependencies
I tried after reinstalling electron-forge as well with "npm install -g electron-forge"
If electron-forge start get's passed the "Locating application" phase we believe the required config is there. This does not mean that you have everything installed correctly however.
Try completely recloning your repository, who knows what could have been deleted / edited / broken.
thanks @MarshallOfSound. will try it out
If electron-forge start get's passed the "Locating application"
phase we believe the required config is there
in my case the application is starting up but the above error is thrown
and this happens only on windows. application starts and works on OSX
there was a separate error on OSX
due to hard disk getting full. but there was no such issue on windows. ie. hard disk was not full etc
so not sure why this error is occurring
so i suggested a "homebrew doctor" command
so check all the dependencies
even a list of manual steps to check the system would be nice to have
re-installing the whole system (in case it stops working) does seems painful
@deepak I'm not sure what to tell you, I cloned your repository onto a Windows 10 machine and ran yarn followed by electron-forge start. It worked perfectly.
Whatever error you are getting appears to be due to the compiler not kicking in which normally occurs due to a misconfigured .compilerc.
As such the best I can suggest (as I said before) is effectively recloning your repository and starting the same way I did. If the error still occurs on a clean clone of your repository on your machine I can potentially look into more debugging
@MarshallOfSound it worked after
Same error here but the steps described by deepak above does not help in my case.
@krimark do you have a minimal, sample app that we can use to reproduce?
Hi, what I do is to simply initialize a new projekt using the angular 2 template from here: https://beta.electronforge.io/templates and I also add electron to the dev dependencies with npm install electron --save-dev because otherwise I get red squiggles in VS Code on the line import { app, BrowserWindow } from 'electron'; If I just run the code without first installing electron it seems to work but I don't understand why as electron is not present in node_modules at that time.
Yeah, don't install electron directly onto the project. electron is a dependency of electron-prebuilt-compile (which is installed by default), but it does not install electron into the top-level node_modules (because of installation conflicts). What you're seeing with the red squiggle _sounds_ like a VSCode bug.
Most helpful comment
Yeah, don't install
electrondirectly onto the project.electronis a dependency ofelectron-prebuilt-compile(which is installed by default), but it does not installelectroninto the top-levelnode_modules(because of installation conflicts). What you're seeing with the red squiggle _sounds_ like a VSCode bug.