When dealing with `fs` library, the common problem you will meet is the path to file.

Different envs may have different way to handle the path.

The best way which works for all is `require.resolve`:

  const script = fs.readFileSync(require.resolve("./image.js"), "utf-8");

 

相关文章:

  • 2022-12-23
  • 2021-06-13
  • 2021-10-17
  • 2021-12-03
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2021-08-24
猜你喜欢
  • 2022-12-23
  • 2021-12-28
  • 2021-08-24
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案