我想基於this tutorial的WebPack找不到模塊「電子」
看來,開發一個小電子angular2應用他們的一些誤差的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'.
只是想提一提,當一個人切換回使用老版本的電子(例如v0.30.6支持serialport-electron)時,也可能發生這種錯誤仍然使用'var app = require('app');'等等而不是'const electron = require('electron');' - 參見https://github.com/atom/electron/blob/v0.30.6 /docs/tutorial/quick-start.md – iX3