添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Module not found: Error: Can't resolve 'fs' #91

@TheColorRed

Description

When I add the @electron/remote module, I get an error in node_modules\electron\index.js giving the following error:

./node_modules/electron/index.js:1:11-24 - Error: Module not found: Error: Can't resolve 'fs' in 'C:...\node_modules\electron'

The app also does not start up. This is what I did in my main app:

const { app, BrowserWindow, ipcMain } = require('electron')
require('@electron/remote/main').initialize()
let win
function createWindow() {
  win = new




    
 BrowserWindow({
    width: 1024,
    height: 650,
    minWidth: 1024,
    minHeight: 650,
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true,
      contextIsolation: false
  require('@electron/remote/main').enable(win.webContents)
app.on('ready', createWindow)

I have also tried

const { app, BrowserWindow, ipcMain, webContents } = require('electron')
require('@electron/remote/main').initialize()
require('@electron/remote/main').enable(webContents)

Then in my Angular app, I have the following:

import { Injectable } from '@angular/core'
const remote = require('@electron/remote')
@Injectable({ providedIn: 'root' })
export class SettingsService {
  constructor() {
    console.log('remote', remote.require('fs'))
}