我正在尝试使用 angular 制作 Electron 应用。
我遵循了教程 here .相当整洁的工作。 但我正在尝试使用 native 节点模块,特别是“fs”
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 config有关,但是不知道怎么改这些配置...
最佳答案
您可能需要调整 webpack 配置
- 应用正确的目标(https://webpack.js.org/configuration/target/#string)
- 应用正确的
externals
以不捆绑 nodejs 端模块。
关于angular - Electron Angular App,如何使用原生节点模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48256245/