0

I'm trying to work with PPTXGenJS in a SharePoint's WebPart and therefore need to import the npm package. Unfortunately, I'm not able to make it available in my program, since code is telling me that a declaration file is missing. npm install @types/pptxgenjs@latest just throws an error and even appending a new pptxgenjs.d.ts file declaring the module does not work.

Do you have any ideas what I can do here?

Thank you!

Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73
Daniel
  • 1
  • 1

2 Answers2

0

Types were made available by the author the old way (DefinitelyTyped). This is the reason why "npm install @types/pptxgenjs@latest" does not work.

Try "npm install pptxgenjs", or add it to your dependencies in the package.json file, like this:

"dependencies": { "pptxgenjs": "^2.3.0" }

This will install the dependency, and types will be available at dist/pptxgenjs

Diego
  • 713
  • 5
  • 19
  • Thank you! I've tried this before, but unfortunately the code that is loaded with the npm install pptxgenjs is not the latest. I manually had to post the code from the git-repo into my index.d.ts file. – Daniel Nov 13 '18 at 11:53
0

environment: node 16.18.0 + typescript: 4.3.5

running command: ts-code test.ts

After research for hours, this solution works for me:

// test.ts
const PptxFile = require('pptxgenjs');
const pptx = new PptxFile();
let slide = pptx.addSlide();
slide.addText('Hello World from PptxGenJS...');
pptx.writeFile({ fileName: 'Sample Presentation.pptx' });
hootf4
  • 1
  • 3