Module not found: Can't resolve 'fs'
Unanswered
White-tailed Ptarmigan posted this in #help-forum
White-tailed PtarmiganOP
im trying to import fs and keep getting the error in the title. Im pretty sure im importing it from the server side. this is the file im importing it from. its in the root of my project (not app directory).
import fs from "fs"
import openai from "./OpenaiClient"
if (!openai) {
throw new Error("OPENAI_API_KEY is required")
}
export async function getAssistant() {
const file = await openai.files.create({
file: fs.createReadStream("../bls/BLS_Test.json"),
purpose: "assistants",
})
random code ......
}
import fs from "fs"
import openai from "./OpenaiClient"
if (!openai) {
throw new Error("OPENAI_API_KEY is required")
}
export async function getAssistant() {
const file = await openai.files.create({
file: fs.createReadStream("../bls/BLS_Test.json"),
purpose: "assistants",
})
random code ......
}
7 Replies
Why is it NOT in your app directory?
Himalayan
I think fs can't work in nextjs yet
@Himalayan I think fs can't work in nextjs yet
it is working for me?
@Ray it is working for me?
Himalayan
Are you sure the other day I tried it's not working and when I look it up online still see the same answer
@Himalayan Are you sure the other day I tried it's not working and when I look it up online still see the same answer
yeah Im sure it is working on the server side but not on client in nodejs runtime
@Ray yeah Im sure it is working on the server side but not on client in nodejs runtime
Himalayan
oh! that's cool @White-tailed Ptarmigan sorry for the wrong answer