Reading files from a directory inside a meteor app

后端 未结 7 599
既然无缘
既然无缘 2021-01-04 08:28

How can i read the public directory in a meteor application inside my /server path.

I tried using the native \'fs\' package but i keep getting a file/di

相关标签:
7条回答
  • 2021-01-04 09:03

    On the server you can use fs to access any part of the meteor directory tree, not just /public, for example

    import fs from 'fs';
    const rd = process.env.PWD;
    const obj = JSON.parse(fs.readFileSync(`${rd}/private/file.json`));
    

    would read and parse a json file located at private/file.json under your meteor app directory root.

    0 讨论(0)
提交回复
热议问题