
$ npm config set electron_custom_dir 8.1.1 # バージョン番号によって決定
Error:resource\\trtc_electron_sdk.node is not a valid Win32 applicationというエラーが表示されます。32ビットのtrtc_electron_sdk.nodeが必要ということでしょうか。
npm run install -- arch=ia32
trtc_electron_sdk.nodeのダウンロードを完了後、項目を再度パッケージ化します。cd ~/Library/Application\\ Support/com.apple.TCC/cp TCC.db TCC.db.baksqlite3 TCC.db # sqlite> prompt appears.# for Mojave, CatalinaINSERT into access VALUES('kTCCServiceCamera',"com.microsoft.VSCode",0,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);# for BigSurINSERT into access VALUES('kTCCServiceCamera',"com.microsoft.VSCode",0,1,1,1,NULL,NULL,NULL,'UNUSED',NULL,0,1541440109);
“cannot read property 'dlopen' of undefined”がスローされてしまいます。
let win = new BrowserWindow({width: 1366,height: 1024,minWidth: 800,minHeight: 600,webPreferences: {nodeIntegration: true,contextIsolation: false},});
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
npm config get cacheを実行し、キャッシュディレクトリを確認します。npm installを実行します。csrutil disableと入力し、保護メカニズムを無効化します。csrutil enableを実行します。xx is not defined と表示されます。この xx には node モジュールが入ります。例えば次のようになります。Uncaught ReferenceError: require is not defined
main.js ファイルで nodeIntegration 設定項目を true に変更します。let win = new BrowserWindow({width: 1366,height: 1024,webPreferences: {nodeIntegration: true, // この項目をtrueに設定してください},});
NodeRTCCloud is not a constructor
Cannot open xxx/trtc_electron_sdk.nodeまたはThe specified module could not be found
dlopen(xxx/trtc_electron_sdk.node, 1): image not found
native-ext-loaderをインストールします。$ npm i native-ext-loader -D
webpack.config.jsを構築する際、 受信名を--target_platformのコマンドラインパラメータにできるため、コードの構築プロセスで異なる目標プラットフォームの特徴に応じて正しくパッケージできます。 module.exportsの前に以下のコードを追加します。const os = require('os');// target_platformパラメータが渡されない場合、プログラムはデフォルトで現在のプラットフォームタイプに応じてパッケージしますconst targetPlatform = (function(){let target = os.platform();for (let i=0; i<process.argv.length; i++) {if (process.argv[i].includes('--target_platform=')) {target = process.argv[i].replace('--target_platform=', '');break;}}// win32 は統一してWindowsプラットフォームを表し、32ビットと64ビットのどちらも含まれます。darwinはMacプラットフォームを表しますif (!['win32', 'darwin'].includes) target = os.platform();return target;})();
module: {rules: [{test: /\\.node$/,loader: 'native-ext-loader',options: {rewritePath: targetPlatform === 'win32' ? './resources' : '../Resources'}},]}
vue-cliを使用して作成した項目については、webpack設定はvue.config.jsファイルのconfigureWebpackオプションに保存されます。create-react-appを使用して作成した項目については、webpack設定ファイルは[プロジェクトディレクトリ]/node_modules/react-scripts/config/webpack.config.jsとなります。electron-builderパッケージ設定を追加します(大文字と小文字の区別に注意)。"build": {"省略": "...","win": {"extraFiles": [{"from": "node_modules/trtc-electron-sdk/build/Release/","to": "./resources","filter": ["**/*"]}]},"mac": {"extraFiles": [{"from": "node_modules/trtc-electron-sdk/build/Release/trtc_electron_sdk.node","to": "./Resources"}]},"directories": {"output": "./bin"}},
create-react-app項目の追加については次の設定をご参照ください。"scripts": {"build:mac": "react-scripts build --target_platform=darwin","build:win": "react-scripts build --target_platform=win32","compile:mac": "node_modules/.bin/electron-builder --mac","compile:win64": "node_modules/.bin/electron-builder --win --x64","pack:mac": "npm run build:mac && npm run compile:mac","pack:win64": "npm run build:win && npm run compile:win64"}
vue-cli項目については次の設定をご参照ください。"scripts": {"build:mac": "vue-cli-service build --target_platform=darwin","build:win": "vue-cli-service build --target_platform=win32","compile:mac": "node_modules/.bin/electron-builder --mac","compile:win64": "node_modules/.bin/electron-builder --win --x64","pack:mac": "npm run build:mac && npm run compile:mac","pack:win64": "npm run build:win && npm run compile:win64"}
create-react-appを使用して作成した項目を、electron-builderでパッケージ化する際にこの問題が起きることがあります。$ node_modules\\.bin\\electron-builder.cmd• electron-builder version=22.6.0 os=6.1.7601• loaded configuration file=package.json ("build" field)• public/electron.js not found. Please see https://medium.com/@kitze/%EF%B8%8F-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3• loaded parent configuration preset=react-cra
public/electron.js not foundが、エントリーファイルが見つからないことを意味しています。$ cd [項目ディレクトリ]$ mv main.electron.js ./public/electron.js
{"main": "public/electron.js","省略": "..."}
[プロジェクトディレクトリ]\\node_modules\\electron-builder\\node_modules\\fs-extra\\lib\\empty\\index.js:33} catch {^SyntaxError: Unexpected token {at new Script (vm.js:51:7)
フィードバック