Greetings!
Not sure if this issue would fit better on now-builders, but here we go.
Is there a way to avoid the necessity of __dirname when trying to import files locally?
This is our current usage:
.
├── now.json
├── package.json
└── src
├── index.js
└── temp.txt
index.js:
const {send} = require('micro')
const fs = require('fs')
const {promisify} = require('util')
const readFile = promisify(fs.readFile)
module.exports = async (req, res) => {
const read = await readFile( __dirname + "/temp.txt")
return send(res, 200, read.toString())
}
Many users face problems when doing readFile( "./temp.txt"), and the solution is above. But is there a way to avoid it?
Greetings!
Not sure if this issue would fit better on
now-builders, but here we go.Is there a way to avoid the necessity of
__dirnamewhen trying to import files locally?This is our current usage:
index.js:Many users face problems when doing
readFile( "./temp.txt"), and the solution is above. But is there a way to avoid it?