微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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;

原文地址:https://www.jb51.cc/angularjs/142030.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐