Cannot import ES6 modules on windows
See original GitHub issueThe 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
Console output when you run electron-forge
with the environment variable DEBUG=electron-forge:*
.
PS C:\Users\Deepak\Documents\Visual Studio 2013\Projects\electron-webview-todo> npm start
> electron-webview-todo@0.0.1 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)
What command line arguments are you passing?
command to start Elecron is:
cross-env DEBUG=* electron-forge start --enable-logging
What does your 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": ""
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Cannot import ES6 modules on windows #93 - electron/forge
The same code was running on Windows and OSX. But it randomly stopped working on Windows 10. error is: import { app, BrowserWindow...
Read more >Node.js unable to import ES6 module - Stack Overflow
Node.js unable to import ES6 module · 1. Have you tried to change import { router } from './routes'; to import router from...
Read more >JS Fix For "SyntaxError: Cannot Use Import Statement Outside ...
This is most likely triggered when a file tries to use both import and require module patterns, which isn't possible. You'll need to...
Read more >ECMAScript Modules - Jest
If your codebase includes ESM imports from *.wasm files, you do not need to pass --experimental-wasm-modules to node .
Read more >How To Use Modules in TypeScript | DigitalOcean
Modules are a way to organize your code into smaller, more manageable pieces, allowing programs to import code from different parts of the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, don’t install
electron
directly onto the project.electron
is a dependency ofelectron-prebuilt-compile
(which is installed by default), but it does not installelectron
into the top-levelnode_modules
(because of installation conflicts). What you’re seeing with the red squiggle sounds like a VSCode bug.@MarshallOfSound it worked after