2017-05-28 18 views
2

私は電子と電子パッケージャをすべてグローバルモードでインストールしました。私のアプリをビルドすると、電子パッケージャーはローカルの電子モジュールを検索します。どのように電子パッケージャに、私がインストールしたグローバル電子モジュールを使用するのを強制するのですか?電子パッケージャーとgloabl電子モジュール

答えて

1

あなたが説明したことは、電子パッケージャを使用する方法ではありません。通常は、あなたが作業しているプロジェクトディレクトリの下にローカルパッケージ(exeまたはそのようなもの)を構築しているということです。たとえば、Windowsプラットフォーム上での電子/角度のプロジェクトの建物は、構造体の以下のようなものかもしれません:

:シナリオのこの種では

C:. 
+---ClientSide 
¦ +---index.html 
¦ +---app 
¦ ¦ +---app.component.ts 
¦ ¦ +---app.module.ts 
¦ ¦ +---main.ts 
¦ ¦ +---AppContent/ 
¦ ¦ +---help/ 
¦ +---Styles 
¦ +---test 
¦  +---AppContent/ 
+---dist/ 
+---edist 
| \---Application-win32-ia32 [*location of binary source for the install] 
+---Installer 
    +---Application/ 
gulpfile.js 
karma.conf.js 
main.js 
package.json 
README.md 
webpack.config.js 

を、package.jsonファイルは、通常のように、両方のパッケージへの参照が含まれています

.. .. .. 
    "devDependencies": { 
    "@angular/animations": "4.4.4", 
    "@angular/common": "4.4.4", 
    "@angular/compiler": "4.4.4", 
.. .. .. 
.. .. .. 
    "electron": "1.7.9", 
    "electron-packager": "9.1.0", 
.. .. .. 

ローカルgulpfile.jsには、通常、電子のローカルバージョンを参照するパッケージャを実行する呼び出しが含まれます。ような何か:

'use strict'; 
... ... 
var packager = require('electron-packager'); 
var electronPackage = require('electron/package.json'); 
var pkg = require('./package.json'); 
// pull the electron version from the package.json file 
var electronVersion = electronPackage.version; 
... ... 

var opts = { 
    name: pkg.name, 
    platform: 'win32', 
    arch: 'ia32',       // ia32, x64 or all 
    dir: './',      // source location of app 
    out: './edist/',    // destination location for app os/native binaries 
    ignore: config.electronignore,   // don't include these directories in the electron app build 
    icon: config.icon, 
    asar: {unpackDir: config.electroncompiled}, // compress project/modules into an asar blob but don't use asar to pack the native compiled modules 
    overwrite: true, 
    prune: true, 
    electronVersion: electronVersion ,  // Tell the packager what version of electron to build with 
    appCopyright: pkg.copyright,   // copyright info 
    appVersion: pkg.version,   // The version of the application we are building 
    win32metadata: {      // Windows Only config data 
     CompanyName: pkg.authors, 
     ProductName: pkg.name, 
     FileDescription: pkg.description, 
     OriginalFilename: pkg.name + '.exe' 
    } 
}; 


// Build the electron app 
gulp.task('build:electron', function (cb) { 

    console.log('Launching task to package binaries for ' + opts.name + ' v' + opts['appVersion']); 

    packager(opts, function (err, appPath) { 
     console.log(' <- packagerDone() ' + err + ' ' + appPath); 
     console.log(' all done!'); 
     cb(); 
    }); 
}); 

ローカルに存在しているとして、あなたはパッケージャを使用したい電子のどんなバージョンにそのパラメータを変更することができ、電子の同じバージョンをビルドしたくない場合。同様に、このコード行を置き換える:

// pull the electron version from the package.json file 
var electronVersion = electronPackage.version; 

このようなもので:

// Use a specific electron version 
var electronVersion = '1.7.8'; 

コマンドラインからelectron-packagerを実行しようとしている場合、あなたは「私のように利用可能なすべて同じオプションを持っていますここでAPIオプションに示されています。オプションin their online github user docsの全リストを見ることができます。あなたの場合、コマンドラインを使用している場合は、 "--electron-version"スイッチを使用して希望の電子バージョンを設定します。

関連する問題