Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

next.js - Unable to fetch excel file in production in nextjs

I have an excel file named Words.xlsx in public directory. Initially, during development mode, setting file path to /public/Words.xlsx worked fine but it failed in production mode saying that it can't read file path. Then, I read this and changed path to/Words.xlsx but I am still receiving the same error(below) in my function logs of vercel.

[Error: ENOENT: no such file or directory, open '/Words.xlsx'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Words.xlsx'
}
ENOENT: no such file or directory, open '/Words.xlsx'

Further, I am using this npm package to read excel file. Below is the code of how I use it:

const res1Sheet = await readXlsxFile('/Words.xlsx', { sheet: 1 });

How do I solve this?

question from:https://stackoverflow.com/questions/65867765/unable-to-fetch-excel-file-in-production-in-nextjs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...