typescript – Webpack找不到模块’电子’

前端之家收集整理的这篇文章主要介绍了typescript – Webpack找不到模块’电子’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试开发一个基于 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'.
解决了它
const electron = require('electron');
const remote = electron.remote;

猜你在找的Angularjs相关文章