how can I use fs in react with electron?

前端 未结 2 1394
难免孤独
难免孤独 2021-02-07 12:55

I want use react+webpack+electron to build a desktop app.How can I inject fs module into react so that I can use it to read native files? I have a component such as

相关标签:
2条回答
  • 2021-02-07 13:16

    The easiest thing to do is probably to use webpack-target-electron-renderer, you can find examples of using it in electron-react-boilerplate.

    0 讨论(0)
  • 2021-02-07 13:21

    use window.require() instead of require().

    const fs = window.require('fs');
    
    0 讨论(0)
提交回复
热议问题