0

I'm trying to use exceljs in a server api on Nuxt for some reason when I deploy to cloudflare I get an error claiming a "message": "Object prototype may only be an Object or null: undefined", import

Any idea why it cant find exceljs but it can find my other imports?

import { readMultipartFormData, sendStream } from 'h3'
import { parse } from 'csv-parse/sync'
import { Readable } from 'stream'


export default defineEventHandler(async (event) => {
  try{
    const { default: ExcelJS } = await import('exceljs')
  }catch (err) {
    // No ExcelJS available; return a 400 error with a very verbose message.
    throw createError({
      statusCode: 400,
      statusMessage: `Error processing file: ExcelJS failed to load. The error message is: ${err.message}. This is likely because this function is running in a server context and the server does not have the ExcelJS module installed. To fix this, add the ExcelJS module to the server dependencies.`
    })
  }
})

This only happens on cloudflare not when I run it locally.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.