Please describe your issue:
In "dev mode" all works right, but once I run a packaged application it throws me that error:
Uncaught Exception:
/Users/rawnly/Code/ELECTRON/APPS/snahp-tool/out/snahp-tool-darwin-x64/snahp-tool.app/Contents/Resources/app/src/app.js:1
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { import { app, BrowserWindow, Menu } from 'electron';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.require.extensions.(anonymous function) [as .js] (/Users/rawnly/Code/ELECTRON/APPS/snahp-tool/out/snahp-tool-darwin-x64/snahp-tool.app/Contents/Resources/app/node_modules/electron-compile/lib/require-hook.js:77:14)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at Object.init (/Users/rawnly/Code/ELECTRON/APPS/snahp-tool/out/snahp-tool-darwin-x64/snahp-tool.app/Contents/Resources/app/node_modules/electron-compile/lib/config-parser.js:294:16)
at Object.<anonymous> (/Users/rawnly/Code/ELECTRON/APPS/snahp-tool/out/snahp-tool-darwin-x64/snahp-tool.app/Contents/Resources/app/es6-shim.js:8:17)
Console output when you run electron-forge with the environment variable DEBUG=electron-forge:*. (Instructions on how to do so here). Please include the stack trace if one exists.
What command line arguments are you passing?
What does your config.forge data in package.json look like?
"config": {
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {
"packageManager": "yarn"
},
"electronWinstallerConfig": {
"name": "snahp_tool"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {},
"github_repository": {
"owner": "Rawnly",
"name": "rawnly/snahp-downloader"
},
"windowsStoreConfig": {
"packageName": "",
"name": "snahptool"
}
}
}
Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using electron-forge init is a good starting point, if that is not the
source of your problem.
What does your .compilerc look like?
{
"env": {
"development": {
"application/javascript": {
"presets": [
[
"env",
{
"targets": {
"electron": "1.8"
}
}
],
"react"
],
"plugins": [
"transform-async-to-generator"
],
"sourceMaps": "inline"
}
},
"production": {
"application/javascript": {
"presets": [
[
"env",
{
"targets": {
"electron": "1.8"
}
}
],
"react"
],
"plugins": [
"transform-async-to-generator"
],
"sourceMaps": "none"
}
}
}
}
In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using electron-forge init as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?
@malept It's easy to reproduce this - I have this issue as well.
The trouble is that you cannot import any ES6 module from node_modules. So if you simply add a folder name _test to your node_modules with anindex.js file containing a one-liner like say import React from 'react' this will not work.
It looks like electron-forge ignores node_modules completely.
Is there any way to modify that somewhere so that it ignores everything except a few selected modules?
Duplicate #212
Most helpful comment
@malept It's easy to reproduce this - I have this issue as well.
The trouble is that you cannot import any ES6 module from
node_modules. So if you simply add a folder name_testto yournode_moduleswith anindex.jsfile containing a one-liner like sayimport React from 'react'this will not work.It looks like electron-forge ignores
node_modulescompletely.Is there any way to modify that somewhere so that it ignores everything except a few selected modules?