[Node.js] Resolve path problem in all envs (require.resolve)

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");

 

上一篇:egg-static, 静态资源配置


下一篇:linus常用命令 (小白防止忘记,不断更新)