Electron Angular应用程序,如何使用本机节点模块
我正在尝试使用angular制作一个电子应用程序 我遵循了教程。干得不错。 但我尝试使用本机节点模块,特别是“fs”Electron Angular应用程序,如何使用本机节点模块,angular,webpack,electron,angular-cli,Angular,Webpack,Electron,Angular Cli,我正在尝试使用angular制作一个电子应用程序 我遵循了教程。干得不错。 但我尝试使用本机节点模块,特别是“fs” import { Injectable } from '@angular/core'; import * as fs from 'fs'; @Injectable() export class FilesService { constructor() { } someMethod() { return fs.lstat('./'); } } 我在构建应用
import { Injectable } from '@angular/core';
import * as fs from 'fs';
@Injectable()
export class FilesService {
constructor() { }
someMethod() {
return fs.lstat('./');
}
}
我在构建应用程序时遇到以下错误:
src/app/shared/files.service.ts(2,21)中出现错误:错误TS2307:找不到模块“fs”。
在网上冲浪一段时间后,我发现它与angular cli生成的webpack配置有关,但我不知道如何更改这些配置…您可能需要调整webpack配置
externals
应用于不捆绑nodejs端模块我使用angular cli制作了这个应用程序,它通过angular-cli.json配置webpack,我是否可以覆盖生成的webpack配置,或者我是否必须推出自己的webpack配置并放弃angular cli项目?好的,所以我使用了ng eject--build and configured webpack.config`“target”:“electron renderer”,“externals”:{“fs”:require(“fs”)}`仍然不起作用。无需担心添加“target”后一切都会正常进行:“electron renderer”无需触摸外部。