为什么`package.json`中列出的`electron-packager`捆绑节点模块不能作为依赖关系?

我一直在为此奋斗了一个星期,所以我想我会联系到惊人的SO社区寻求帮助。 我有一个需要生成OS X应用程序的电子项目(最终是Windows)。 最初我们使用webpack来捆绑所有的东西( electron和前端代码),但是增加了一些利用ffi特性,这不再是一个select。 切换到使用gulp transpile和uglify electron代码后,该应用程序正在开发中。

我遇到的问题是,当使用electron-packager ,我的node_modules在构build期间没有被捆绑。 根据文档, electron-packager 应该捆绑package.json dependencies部分列出的任何东西。 我构build了一个简单的概念validation应用程序来简化事情,模块仍然没有捆绑在electron代码中。 这个新的,简化的项目只是试图包括bunyan (这也失败了),但build设后,应用程序抱怨bunyan模块无法find。 有人可以帮忙吗? 我错过了一些小而重要的东西吗? 以下是该项目的一些细节:

环境细节

  • OSX版本 :10.11.6(15G1108)
  • 节点版本 :5.2.0(使用nvm
  • npm版本 :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 <zachary.abresch@gmail.com>", "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/, }, ], }, }; 

我正在考虑尝试electron-builder但我真的觉得这应该是工作。 如果有人有任何信息或洞察力,我将不胜感激。 如果您需要任何其他信息,请在评论中告知我。 谢谢!