fs.readFileSync is not a function Meteor, React

后端 未结 3 2083
栀梦
栀梦 2020-12-18 05:31

I\'m getting a \'fs.readFileSync is not a function\' in Chrome debugger after trying to call readFileSync();

I call it...

const fs = require(\'fs\')         


        
3条回答
  •  失恋的感觉
    2020-12-18 06:04

    I'm getting a 'fs.readFileSync is not a function' in Chrome debugger after trying to call readFileSync();

    fs will not work in the browser. This is by design as to protect your filesystem from potential security threats.

    Using low level Node packages in a browser environment

    If you need access to this in a browser environment, consider making use of Electron which allows you to make use of OS level NodeJS packages in a running instance of Chromium.

提交回复
热议问题