Electron-packager: `electron-packager` is not bundling the Node modules listed in dependencies

Created on 14 Nov 2016  路  32Comments  路  Source: electron/electron-packager

I've been struggling with this for a week now so I thought I'd reach out to the amazing SO community for help. I've got an Electron project that needs to produce an OS X application (and Windows eventually). Initially we were using webpack to bundle everything (electron and front-end code) but, with the addition of some features that utilize ffi, this was no longer an option. After switching to using gulp to transpile and uglify the electron code, the app was working in development.

The problem I'm having is, when using electron-packager, none of my node_modules are being bundled during the build. According to the docs, electron-packager should bundle anything listed in the dependencies section of package.json. I built a simple proof-of-concept app to simplify things and modules still aren't being bundled for the electron code. This new, simplified project is just trying to include bunyan (this also fails for ffi) but, after building, the app complains that the bunyan module cannot be found. Can someone help? Am I missing something small but important? Here's some detail to the project:

Environment Details

  • OSX Version: 10.11.6 (15G1108)
  • Node Version: 5.2.0 (using nvm)
  • npm version: 3.3.12

package.json

    {
        "name": "build-with-native-modules",
        "version": "1.0.0",
        "description": "A test for Electron packages with native Node modules.",
        "main": "el/main.js",
        "scripts": {
          "test": "echo \"Error: no test specified\" && exit 1",
          "clean": "./node_modules/.bin/rimraf build",
          "start": "npm run clean && gulp && ./node_modules/.bin/electron ./build/dist/el/main.js",
          "electron:rebuild": "./node_modules/.bin/electron-rebuild",
          "build:osx": "gulp build:osx",
          "cinstall": "rm -Rf ./node_modules && npm cache clean && npm i && npm run electron:rebuild"
        },
        "postinstall": "install-app-deps",
        "author": "Zachary Abresch <[email protected]>",
        "license": "MIT",
        "dependencies": {
          "bunyan": "^1.8.4",
          "jquery": "^3.1.1"
        },
        "devDependencies": {
          "babel-cli": "^6.18.0",
          "babel-core": "^6.18.2",
          "babel-eslint": "^7.1.0",
          "babel-loader": "^6.2.7",
          "babel-preset-es2015": "^6.18.0",
          "babel-preset-stage-0": "^6.16.0",
          "babel-register": "^6.18.0",
          "electron": "1.4.6",
          "electron-packager": "^8.2.0",
          "electron-rebuild": "^1.3.0",
          "eslint": "^3.9.1",
          "eslint-config-airbnb": "^13.0.0",
          "eslint-plugin-import": "^2.2.0",
          "eslint-plugin-jsx-a11y": "^2.2.3",
          "eslint-plugin-react": "^6.6.0",
          "gulp": "^3.9.1",
          "gulp-babel": "^6.1.2",
          "gulp-util": "^3.0.7",
          "rimraf": "^2.5.4",
          "webpack": "^1.13.3",
          "webpack-dev-server": "^1.16.2"
        }
      }

gulpfile.babel.js

      import gulp from 'gulp';
      import babel from 'gulp-babel';
      import gutil from 'gulp-util';
      import webpack from 'webpack';
      import packager from 'electron-packager';

      import webpackConfig from './webpack.config.babel';
      import pack from './package.json';

      gulp.task('electron:babel', () => {
        gulp.src('src/el/**/*.js', { base: 'src' })
        .pipe(babel())
        .pipe(gulp.dest('build/dist'));
      });

      gulp.task('move:html', () => {
        gulp.src('src/ui/**/*.html', { base: 'src' })
        .pipe(gulp.dest('build/dist'));
      });

      gulp.task('move:package', () => {
        gulp.src('package.json', { base: './' })
          .pipe(gulp.dest('build/dist'));
      });

      gulp.task('ui:webpack', (done) => {
        const myConfig = Object.create(webpackConfig);

        webpack(myConfig, (err, stats) => {
          if (err) throw new gutil.PluginError('ui:webpack', err);
          gutil.log('[ui:webpack]', stats.toString({ colors: true }));
          done();
        });
      });

      const osxBuildOptions = {
        arch: 'x64',
        'app-copyright': '8x8, Inc.',
        'app-version': '1.0.0',
        'build-version': '1.0.0',
        dir: './build/dist',
        name: pack.name,
        out: './build/bundle',
        overwrite: true,
        version: pack.devDependencies.electron,
      };

      gulp.task('build:osx',
        ['move:package', 'electron:babel', 'ui:webpack', 'move:html'],
      (done) => {
        packager(osxBuildOptions, (err, appPath) => {
          if (err) throw new gutil.PluginError('electron-packager', err);
          gutil.log(`[build:osx] App built in: ${appPath}`);
          done();
        });
      });

      gulp.task('default', ['electron:babel', 'ui:webpack', 'move:html']);

webpack.config.babel.js

    import path from 'path';

      module.exports = {
        target: 'electron',
        entry: './src/ui/renderer.js',
        output: {
          path: path.resolve(__dirname, 'build/dist/ui'),
          filename: 'ui.bundle.js',
        },
        module: {
          loaders: [
            {
              loader: 'babel-loader',
              include: [
                path.resolve(__dirname, 'src/ui'),
              ],
              test: /\.js/,
            },
          ],
        },
      };

I'm considering trying out electron-builder but I really feel like this should be working. If anyone has any info or insight I'd greatly appreciate it. If you need any additional information, please let me know in the comments. Thanks!

Console output when you run electron-packager with the environment variable DEBUG=electron-packager. Please include the stack trace if one exists.

$> DEBUG=electron-packager npm run build:osx

> [email protected] build:osx /Users/zabresch/Documents/8x8/scratching/build-with-native-modules
> gulp build:osx

[10:33:26] Requiring external module babel-register
[10:33:27] Using gulpfile ~/Documents/8x8/scratching/build-with-native-modules/gulpfile.babel.js
[10:33:27] Starting 'move:package'...
[10:33:27] Finished 'move:package' after 8.18 ms
[10:33:27] Starting 'electron:babel'...
[10:33:27] Finished 'electron:babel' after 3.8 ms
[10:33:27] Starting 'ui:webpack'...
[10:33:27] Starting 'move:html'...
[10:33:27] Finished 'move:html' after 924 渭s
[10:33:27] [ui:webpack] Hash: b17668fbc87d8c088dcc
Version: webpack 1.13.3
Time: 398ms
       Asset    Size  Chunks             Chunk Names
ui.bundle.js  278 kB       0  [emitted]  main
chunk    {0} ui.bundle.js (main) 268 kB [rendered]
    [0] ./src/ui/renderer.js 449 bytes {0} [built]
    [1] ./~/jquery/dist/jquery.js 267 kB {0} [built]
    [2] external "electron" 42 bytes {0} [not cacheable]
[10:33:27] Finished 'ui:webpack' after 418 ms
[10:33:27] Starting 'build:osx'...
  electron-packager Electron Packager 8.2.0 +0ms
  electron-packager Node v5.2.0 +1ms
  electron-packager Host Operating system: darwin (x64) +0ms
  electron-packager Packager Options: {"arch":"x64","app-copyright":"8x8, Inc.","app-version":"1.0.0","build-version":"1.0.0","dir":"./build/dist","name":"build-with-native-modules","out":"./build/bundle","overwrite":true,"version":"1.4.6"} +0ms
  electron-packager Target Platforms: darwin +0ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Application name: build-with-native-modules +1ms
  electron-packager Target Electron version: 1.4.6 +0ms
  electron-packager Ignored path regular expressions: [ '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"platform":"darwin","arch":"x64","version":"1.4.6"} +6ms
Packaging app for platform darwin x64 using electron v1.4.6
  electron-packager Creating /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64-template +240ms
  electron-packager Extracting /Users/zabresch/.electron/electron-v1.4.6-darwin-x64.zip to /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64-template +0ms
  electron-packager Initializing app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64 from /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64-template template +1s
  electron-packager Ignored paths based on the out param: [ '/Users/zabresch/Documents/8x8/scratching/build-with-native-modules/build/bundle' ] +2ms
  electron-packager Running npm prune --production +9ms
  electron-packager Renaming Electron to build-with-native-modules in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/MacOS +647ms
  electron-packager Renaming Electron Helper to build-with-native-modules Helper in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS +0ms
  electron-packager Renaming Electron Helper.app to build-with-native-modules Helper.app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks +1ms
  electron-packager Renaming Electron Helper EH to build-with-native-modules Helper EH in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper EH.app/Contents/MacOS +0ms
  electron-packager Renaming Electron Helper EH.app to build-with-native-modules Helper EH.app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks +1ms
  electron-packager Renaming Electron Helper NP to build-with-native-modules Helper NP in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper NP.app/Contents/MacOS +0ms
  electron-packager Renaming Electron Helper NP.app to build-with-native-modules Helper NP.app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks +0ms
  electron-packager Moving /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64 to build/bundle/build-with-native-modules-darwin-x64 +1ms
[10:33:29] [build:osx] App built in: build/bundle/build-with-native-modules-darwin-x64
[10:33:29] Finished 'build:osx' after 2.02 s
question

Most helpful comment

@malept I'm also running into this. It seems like electron-packager doesn't play well with npm packages that have been hoisted to a node_modules parent folder. Is that by design?

We're using yarn workspaces and npm packages get hoisted automatically to the root of the mono repo.

All 32 comments

BTW, when I run the .app that's generated I get the following error in Electron:

Uncaught Exception:
Error: Cannot find module 'bunyan'
    at Module._resolveFilename (module.js:455:15)
    at Function.Module._resolveFilename (/Users/zabresch/Documents/8x8/scratching/build-with-native-modules/build/bundle/build-with-native-modules-darwin-x64/build-with-native-modules.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/zabresch/Documents/8x8/scratching/build-with-native-modules/build/bundle/build-with-native-modules-darwin-x64/build-with-native-modules.app/Contents/Resources/app/el/main.js:13:15)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

main.js

import { app, BrowserWindow, ipcMain } from 'electron';
import path from 'path';
import url from 'url';
import bunyan from 'bunyan';

const log = bunyan.createLogger({ name: 'build-with-native-modules' });

let win;

function createWindow() {
  win = new BrowserWindow({ width: 600, height: 800 });

  win.loadURL(url.format({
    pathname: path.resolve(__dirname, '../ui/index.html'),
    protocol: 'file',
    slashes: true,
  }));

  win.openDevTools();

  win.on('closed', () => {
    win = null;
  });

  ipcMain.on('trigger-clicked', (event, msg) => {
    log.info(`trigger confirmation from electron: ${msg}`);
  });
}

app.on('ready', createWindow);

app.on('windows-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (win === null) {
    createWindow();
  }
});

It's probably worth looking at the contents of your .app (since it's really just a fancy folder). Check to see if there's a node_modules folder, and if so, see if bunyan is there.

Yeah, did that and, no, the node_modules folder is _not_ there. I tried it with asar: false too just to see if the app folder would contain it. No luck.

I was under the impression that electron-packager would bundle anything listed in dependencies in package.json. Do I need to manually copy node_modules somewhere? If so, is there a clean way to do that with _just_ the dependencies?

That is unsettling. Perhaps try running Electron Packager outside of the gulp workflow and see what happens? My current hypothesis is that one of your other gulp tasks is interfering with Electron Packager.

Okay. I ran this: ./node_modules/.bin/electron-packager ./build/dist build-with-native-modules --platform=darwin --arch=x64 --out=./build/sa_packager --overwrite=true and it ran without errors.

Did it in DEBUG too:

DEBUG=electron-packager ./node_modules/.bin/electron-packager ./build/dist build-with-native-modules --platform=darwin --arch=x64 --out=./build/sa_packager --overwrite=true
  electron-packager Electron Packager 8.2.0 +0ms
  electron-packager Node v5.2.0 +2ms
  electron-packager Host Operating system: darwin (x64) +2ms
  electron-packager Packager Options: {"_":["./build/dist","build-with-native-modules"],"all":false,"deref-symlinks":true,"download":{"strictSSL":true},"overwrite":true,"prune":true,"platform":"darwin","arch":"x64","out":"./build/sa_packager","dir":"./build/dist","name":"build-with-native-modules","protocols":[]} +1ms
  electron-packager Target Platforms: darwin +0ms
  electron-packager Target Architectures: x64 +0ms
  electron-packager Inferring app-version from version in /Users/zabresch/Documents/8x8/scratching/build-with-native-modules/build/dist/package.json +9ms
  electron-packager Inferring target Electron version from electron in /Users/zabresch/Documents/8x8/scratching/build-with-native-modules/build/dist/package.json +4ms
  electron-packager Application name: build-with-native-modules +0ms
  electron-packager Target Electron version: 1.4.6 +0ms
  electron-packager Ignored path regular expressions: [ '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)',
  '\\.o(bj)?$' ] +0ms
  electron-packager Downloading Electron with options {"strictSSL":true,"platform":"darwin","arch":"x64","version":"1.4.6"} +8ms
Packaging app for platform darwin x64 using electron v1.4.6
  electron-packager Creating /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64-template +278ms
  electron-packager Extracting /Users/zabresch/.electron/electron-v1.4.6-darwin-x64.zip to /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64-template +0ms
  electron-packager Initializing app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64 from /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64-template template +1s
  electron-packager Ignored paths based on the out param: [ '/Users/zabresch/Documents/8x8/scratching/build-with-native-modules/build/sa_packager' ] +2ms
  electron-packager Running npm prune --production +10ms
  electron-packager Renaming Electron to build-with-native-modules in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/MacOS +409ms
  electron-packager Renaming Electron Helper to build-with-native-modules Helper in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS +1ms
  electron-packager Renaming Electron Helper.app to build-with-native-modules Helper.app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks +0ms
  electron-packager Renaming Electron Helper EH to build-with-native-modules Helper EH in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper EH.app/Contents/MacOS +1ms
  electron-packager Renaming Electron Helper EH.app to build-with-native-modules Helper EH.app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks +0ms
  electron-packager Renaming Electron Helper NP to build-with-native-modules Helper NP in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks/Electron Helper NP.app/Contents/MacOS +0ms
  electron-packager Renaming Electron Helper NP.app to build-with-native-modules Helper NP.app in /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64/Electron.app/Contents/Frameworks +1ms
  electron-packager Moving /var/folders/zx/m4gltph949j450_vsv_pt4mjzphjyg/T/electron-packager/darwin-x64/build-with-native-modules-darwin-x64 to build/sa_packager/build-with-native-modules-darwin-x64 +1ms
Wrote new app to build/sa_packager/build-with-native-modules-darwin-x64

Again, there is no node_modules folder in the app directory after packaging. I'm going to put my proof-of-concept up on GH. One sec.

kk. Here's the app I'm using for testing. https://github.com/zacharyabresch/build-with-native-modules

OK. I won't have time to debug this for a while, so I'm just going to ask some questions in the meantime. The only ones I have at the moment are:

  • before you package the Electron app, in the node_modules folder that's in the same directory as package.json, does it have bunyan and jquery?
  • What version of NPM are you using?

Any help is awesome. Thanks for your time.

  • Yes, those packages exist in ./node_modules
  • npm version: 3.3.12

I _have_ had some random issues with npm lately. Is there a version you'd recommend?

Oh, I see. You are copying the app to build/dist first. Does node_modules (and those packages) exist in _that_ directory?

No, but package.json does ... it gets moved there prior to webpack and babel to ./build/dist. Should I copy node_modules to there? Would a symlink work?

Either copy it or run npm install in build/dist before running Electron Packager. A symlink might not work the way you think.

Okay ... after a bit of digging I was able to figure out how to run npm i in build/dist. Here's the gulp task that got it done:

// Installs dependencies into build folder
gulp.task('run:npm-install', shell.task([
  'npm --prefix ./build/dist install ./build/dist --production',
  './node_modules/.bin/electron-rebuild -m ./build/dist/node_modules',
]));

The --production option is key since that _only_ installs dependencies in package.json. Thank you _so_ much for your help on this!

I was experiencing the same issue, but I wasn't using Gulp loaders, so that couldn't be it.

For me, the problem was that main.js was located in ./src/app, which does not contain the node_modules folder.

main.js has to be in the root folder along with package.json and node_modules, that solves the problem.

I was starting from this angular-electron starter which had the file placed there.

@malept I'm also running into this. It seems like electron-packager doesn't play well with npm packages that have been hoisted to a node_modules parent folder. Is that by design?

We're using yarn workspaces and npm packages get hoisted automatically to the root of the mono repo.

Related ticket on yarn's issue tracker: https://github.com/yarnpkg/yarn/issues/4070

I am seeing the same with electron-packager. I am not using yarn or gulp or any other build tool. When I run electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --overwrite=true --out=release-builds to build and run the build, I get the same error about things not in the package. However when I run electron . it runs fine in development. I've looked in the .app package contents from the generated stuff and I don't see everything in node_modules.

@neil-mcglennon-sp it would help if you provided your package.json.

I too am having this issue. To verify it's not my app I snagged the Electron Quick Start, and added a single new package dependency. Runs fine with npm, but fails after packing with the "Cannot Find Module" error.

No modules are in resources/app/node_modules/, only one folder @types which is empty.

Windows 10
Node 6.11.5
Electron Packager v1.8.4

{
  "name": "electron-quick-start",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^1.8.4"
  },
  "dependencies": {
    "line-by-line": "^0.1.6"
  }
}

@tophermade @neil-mcglennon-sp experiencing the same issue here. the app seems to work fine when im using electron-packager-interactive to build the app. but not if i build the app with electron-packager api or cli

package.json:

{
  "name": "imgursnap",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "dependencies": {
    "blob-to-buffer": "^1.2.7",
    "jimp": "^0.2.28",
    "jquery": "^3.3.1",
    "opn": "^5.3.0",
    "request": "^2.85.0"
  },
  "devDependencies": {
    "electron": "^1.8.4",
    "electron-packager": "^12.0.0",
    "electron-packager-interactive": "^0.1.3"
  },
  "scripts": {
    "start": "electron .",
    "build": "node build/dist"
  },
  "author": "",
  "license": "ISC"
}
const packager = require('electron-packager')

const options = {
  platform: ['win32', 'linux'],
  arch: 'x64',
  name: 'imgurSnap',
  icon: './view/images/imgurSnap',
  dir: '.',
  ignore: ['build'],
  out: './build/releases',
  overwrite: true,
  asar: true,
  prune: true
}

packager(options, (error, path) => {
  if (error) {
    return (
      console.log(`Error: ${error}`)
    )
  }

  console.log(`Package created, path: ${path}`)
})

Folks arriving here recently you are all experiencing https://github.com/electron-userland/electron-packager/issues/820

If reinstall your node modules you should get an updated version of Galactus that fixes this issue 馃憤

I am getting same problem as well. :-(

@MarshallOfSound - Sorry I am new to Electron and Node dev. Do you mean try running npm install after deleting the node_modules folder? That doesn't work for me. Still seeing only empty @types folder under node_modules in generated folder.

npm version - 5.6.0
windows 8
electron 1.8.4.

@cballantyne

npm version - 5.6.0

You need to delete your package-lock.json file as well to get newer modules 馃憤

after removing package-lock.json and then running npm update, im still having the same issue

The easiest thing to do is reinstall Electron Packager.

@malept thanks it works now. i was just beeing a dumbass

Thank you. I think reinstalling Electron Packager did the trick as it was still not working after only removing node modules and package-lock.son and then doing npm install.

Hi , i'm having the same issue .
tried all of the above and still it doesn't work.
someone have some other idea?

@eladc898
In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using the electron-quick-start repository as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?

So the issue that I had was due to using src in the ignore option in the building config object. I had the following ignore regex (which was the default for https://github.com/SimulatedGREG/electron-vue)

building: {
    ignore: /\b(src|index\.ejs|icons)\b/,`
}

However this also ignores src folders in node_modules that have to be copied. One npm module that I had issues with was the debug module https://github.com/visionmedia/debug#readme. As you can see there is a src folder in the module which is needed for the module to function. However, because it's ignored, it will throw an error on launch.

Solution: I have renamed my src folder to sourcecode and changed the regex string to /\b(sourcecode|index\.ejs|icons)\b/ (and all references to it) now it runs fine in production.

So the issue that I had was due to using src in the ignore option in the building config object. I had the following ignore regex (which was the default for https://github.com/SimulatedGREG/electron-vue)

building: {
    ignore: /\b(src|index\.ejs|icons)\b/,`
}

However this also ignores src folders in node_modules that have to be copied. One npm module that I had issues with was the debug module https://github.com/visionmedia/debug#readme. As you can see there is a src folder in the module which is needed for the module to function. However, because it's ignored, it will throw an error on launch.

Solution: I have renamed my src folder to sourcecode and changed the regex string to /\b(sourcecode|index\.ejs|icons)\b/ (and all references to it) now it runs fine in production.

Thanks for your answer. It's very helpful for me!馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TracyGJG picture TracyGJG  路  5Comments

TongDaDa picture TongDaDa  路  3Comments

caishengmao picture caishengmao  路  3Comments

Bharwcb picture Bharwcb  路  5Comments

kdawg1406 picture kdawg1406  路  4Comments