-
Notifications
You must be signed in to change notification settings - Fork 61
Labels
enhancementDenotes a suggestion or request aimed at improving or adding new features to the project.Denotes a suggestion or request aimed at improving or adding new features to the project.
Milestone
Description
When attempting to add an attachment using the latest version of jira.js in an Astro project with Node.js v20.10.0, I encounter the following error:
TypeError: form_data_1.default is not a constructor
Steps to Reproduce:
- Initialize a new Astro project with TypeScript.
- Install jira.js and xlsx-populate.
- Use the following code to add an attachment:
import xlsx from "xlsx-populate";
import { Version3Client } from "jira.js";
export const jiraClient = new Version3Client({
host: env.JIRA_HOST,
authentication: {
basic: {
email: env.JIRA_PERSONAL_EMAIL,
apiToken: env.JIRA_PERSONAL_API_TOKEN,
},
},
});
const objectToXLSX = async (object: any): Promise<Buffer> => {
const workbook = await xlsx.fromBlankAsync();
const sheet = workbook.sheet(0);
// Add headers and values
Object.keys(object).forEach((key, index) => {
sheet.row(1).cell(index + 1).value(key).style("bold", true);
sheet.row(2).cell(index + 1).value(object[key]);
});
return await workbook.outputAsync() as Buffer;
};
export const addJiraAttachment = async () => {
const file = await objectToXLSX({ test: "123" });
try {
await JiraClient.issueAttachments.addAttachment({
issueIdOrKey: "123",
attachment: {
file: file,
filename: "user.xlsx",
},
});
console.log("Attachment added successfully.");
} catch (error) {
console.error("Error adding attachment:", error);
}
};
Environment:
Node.js: v20.10.0
typescript: "^5.6.2"
Astro: "^4.15.11",
jira.js: "^4.0.2",
xlsx-populate: "^1.21.0"
form-data: "^4.0.1",
Additional Context:
The error originates from issueAttachments.ts#L426 where it attempts to instantiate form_data_1.default. It appears that the form-data module isn't being imported correctly in an ESM context.
At version "jira.js": "^2.15.5", everything works correctly.
Metadata
Metadata
Assignees
Labels
enhancementDenotes a suggestion or request aimed at improving or adding new features to the project.Denotes a suggestion or request aimed at improving or adding new features to the project.