A PowerPoint file is simply a bunch of mostly XML files zipped. Thus, you can unzip the file to get access to whatever you want. For example, I extracted an empty 1-slide presentation file called "test.pptx" using 7-zip and got this:

Now, this is the app.xml
file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<TotalTime>0</TotalTime>
<Words>0</Words>
<Application>Microsoft Office PowerPoint</Application>
<PresentationFormat>Widescreen</PresentationFormat>
<Paragraphs>0</Paragraphs>
<Slides>1</Slides>
<Notes>0</Notes>
<HiddenSlides>0</HiddenSlides>
<MMClips>0</MMClips>
<ScaleCrop>false</ScaleCrop>
<HeadingPairs>
<vt:vector size="6" baseType="variant">
<vt:variant>
<vt:lpstr>Fonts Used</vt:lpstr>
</vt:variant>
<vt:variant>
<vt:i4>3</vt:i4>
</vt:variant>
<vt:variant>
<vt:lpstr>Theme</vt:lpstr>
</vt:variant>
<vt:variant>
<vt:i4>1</vt:i4>
</vt:variant>
<vt:variant>
<vt:lpstr>Slide Titles</vt:lpstr>
</vt:variant>
<vt:variant>
<vt:i4>1</vt:i4>
</vt:variant>
</vt:vector>
</HeadingPairs>
<TitlesOfParts>
<vt:vector size="5" baseType="lpstr">
<vt:lpstr>Arial</vt:lpstr>
<vt:lpstr>Calibri</vt:lpstr>
<vt:lpstr>Calibri Light</vt:lpstr>
<vt:lpstr>Office Theme</vt:lpstr>
<vt:lpstr>PowerPoint Presentation</vt:lpstr>
</vt:vector>
</TitlesOfParts>
<LinksUpToDate>false</LinksUpToDate>
<SharedDoc>false</SharedDoc>
<HyperlinksChanged>false</HyperlinksChanged>
<AppVersion>16.0000</AppVersion>
</Properties>
As you can see, among other things, it includes the number of slides. In other words, simply unzip the presentation file using your choice of the several available unzipping NPM packages and read the XML file inside it.