React Js require 'fs'

前端 未结 2 392
悲&欢浪女
悲&欢浪女 2020-12-17 10:46

I have

import fs from \'fs\'

and in my package.json I have

Then I run the command

2条回答
  •  孤街浪徒
    2020-12-17 11:28

    It's possible this might be an environment issue. It's not possible for the browser to interpret and run some Node server-side modules like fs.

    The solution is to run the fs methods in a Node environment (server-side) or to find a package which offers the same functionality but written for the browser.

    It's discussed in this question... Module not found: Error: Cannot resolve module 'fs'

    And this question... Use fs module in React.js,node.js, webpack, babel,express

提交回复
热议问题