加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 07:27:11 所属栏目:安全 来源:网络整理
导读:我正在尝试开发一个基于 this tutorial的小电子角度2应用程序 看起来他们是捆绑webpack的一些错误,因为我不能在我的渲染器组件中需要/导入电子遥控器. 在我的AppComponent中,我执行以下操作 import {remote} from 'electron'; 我的Webpack配置 var path = re
我正在尝试开发一个基于 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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读