我正在尝试开发一个基于
this tutorial的小电子角度2应用程序
看起来他们是捆绑webpack的一些错误,因为我不能在我的渲染器组件中需要/导入电子遥控器.
在我的AppComponent中,我执行以下操作
import {remote} from 'electron';
我的Webpack配置
var path = require('path'); var webpack = require('webpack'); var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin; var webpackTargetElectronRenderer = require('webpack-target-electron-renderer'); var config = { debug: true,devtool: 'source-map',entry: { 'angular2': [ 'rxjs','reflect-Metadata','angular2/core','angular2/router','angular2/http' ],'app': './src/app/renderer/bootstrap' },output: { path: __dirname + '/build/',publicPath: 'build/',filename: '[name].js',sourceMapFilename: '[name].js.map',chunkFilename: '[id].chunk.js' },resolve: { extensions: ['','.ts','.js','.json','.css','.html'],packageMains: ['webpack','browser','web','browserify',['jam','main'],'main'] },module: { loaders: [ { test: /\.ts$/,loader: 'ts',exclude: [ /node_modules/ ] } ] },plugins: [ new CommonsChunkPlugin({ name: 'angular2',filename: 'angular2.js',minChunks: Infinity }),new CommonsChunkPlugin({ name: 'common',filename: 'common.js' }) ] }; config.target = webpackTargetElectronRenderer(config); module.exports = config;
Webpack引发以下错误
ERROR in ./src/app/renderer/components/app/app.ts (1,22): error TS2307: Cannot find module 'electron'.
解决了它
原文链接:https://www.f2er.com/angularjs/142030.htmlconst electron = require('electron'); const remote = electron.remote;