【发布时间】:2017-03-20 01:14:44
【问题描述】:
我的渲染器进程中不需要内部模块。 当我想要内部节点模块甚至电子时,我得到一个错误或未定义或空对象。
例如:
import * as fs from 'fs';
console.log(fs) // empty object
import { spawn } from 'child_process'; // Can't find child_process module
import * as electron from 'electron' // fs.readFileSync is not a function
这是我的代码: 电子
import { app, BrowserWindow } from 'electron';
let mainWin = null;
const loadURL = `http://localhost:4200`;
const createWindow = () => {
mainWin = new BrowserWindow({
width: 800,
height: 800
});
mainWin.loadURL(loadURL);
mainWin.on('closed', () => {
mainWin = null;
});
}
app.on('ready', createWindow);
app.on('activate', () => {
if (!mainWin) {
createWindow();
}
});
和渲染器处理Angular代码:
import { Component } from '@angular/core';
import { readdirSync } from 'fs';
import { spawn } from 'child_process';
console.log(readdirSync);
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.styl']
})
export class AppComponent {
constructor() {}
}
我做错了什么?
【问题讨论】:
标签: angular typescript electron angular-cli