Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
Import Javascript modules in Yeoman Excel add-in project

I'm trying to create an Excel add-in with Yeoman generator. In the excel_project/src/taskpane/taskpane.js file I'd like to call the 'fs' library. When I execute taskpane.js alone on my terminal, everything works fine. However, when I launch the whole Excel project (npm start on my terminal) I have a module import error (see image). It's as if modules couldn't be imported in the Excel add-in... Does anyone have any ideas ? Thanks for your help.

Here is the taskpane.js file, like it is created by Yeoman. I've just added const fs = require('fs'); // this gives the error

Office.onReady((info) => {
  if (info.host === Office.HostType.Excel) {
    document.getElementById("sideload-msg").style.display = "none";
    document.getElementById("app-body").style.display = "flex";
    document.getElementById("run").onclick = run;
  }
});

export async function run() {
  try {

    const fs = require('fs'); // this gives the error

    
    await Excel.run(async (context) => {

      const range = context.workbook.getSelectedRange();
      let text = document.querySelector('textarea').value;

      // Read the range address
      range.load("address");

      // Update the fill color
      range.format.fill.color = "yellow";

      await context.sync();
      console.log(`The range address was ${range.address}.`);
    });
  } catch (error) {
    console.error(error);
  }

}

Here is the error message: enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda