最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Module not found: Can't resolve 'fs' in Next.js application - bun compiler - Stack Overflow

programmeradmin1浏览0评论

I have several problems, first one I have to save in my mariadb an information from a PDF, I have been using libraries or trying with JS native to extract it and save it but its imposible. My project is a NEXT.js v14 but I compile with bun, its "similar" but not the same, because when I tried to download parsePdf it happened the message "Module not found: Can't resolve 'fs'"

I have been watching how to solve the problem with webpack 4-5 but not with bun. For this problem the only solution I thought is create a micro service for this until the fs modulo wont be a problem

const arrayBufferToBuffer = (arrayBuffer) => {
 return Buffer.from(new Uint8Array(arrayBuffer)); 
};



const insertBlobData = async (files, attachmentID, userId) => { 
try { const fileList = Array.isArray(files) ? files : [files];

const fileRequests = fileList.map((file) => {
  const fileData = {
    blobID: generateUUID(),
    attachmentID,
    name: file.name,
    extension: 'pdf',
    data: arrayBufferToBuffer(file.data), // Convertimos el ArrayBuffer a Buffer
    createdBy: userId.providerID,
    createdAt: sqlFormattedDate(new Date()),
    updatedBy: null,
    updatedAt: null,
    erasedBy: null,
    erasedAt: null,
  };   
savedata ETC
}}
发布评论

评论列表(0)

  1. 暂无评论