require file as string

后端 未结 5 1114
日久生厌
日久生厌 2020-12-13 03:33

I\'m using node + express and I am just wondering how I can import any file as a string. Lets say I have a txt file all I want is to load it into a variable as such.

5条回答
  •  自闭症患者
    2020-12-13 03:46

    you'll have to use readFile function from filesystem module.

    http://nodejs.org/docs/v0.3.1/api/fs.html#fs.readFile

提交回复
热议问题