Issues with NPM package "imagemin"

I’m trying to add the imagemin package to my project through NPM and having some issues - I’ve never used imagemin package before, but this seems to be a Meteor related issue.

First off, it seemed “require” statements are not working, only import is working, so I have to treat the syntax (from the NPM documentation) a bit different. NPM example has:

const imagemin = require('imagemin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const imageminPngquant = require('imagemin-pngquant');
 
imagemin(['images/*.{jpg,png}'], 'build/images', {
    plugins: [
        imageminMozjpeg({targa: true}),
        imageminPngquant({quality: '65-80'})
    ]
}).then(files => {
    console.log(files);
    //=> [{data: <Buffer 89 50 4e …>, path: 'build/images/foo.jpg'}, …] 
});

But as mentioned, the “require” statements are simply not working. It gives me errors about cannot find module.

Also, I tried using the syntax in the Meteor guide (with import, and then require), and that doesn’t work because of duplicate declaration.

So the only choice to get this segment working was to switch the “require” statements over to “import” statements.

But now I’m getting a list of errors:

This seems a bit strange to me, it’s mentioned roles.js which is a completely unrelated file, and it simply has a validation function. If I comment out the whole roles.js file, then it gives me errors from other collections.

Furthermore, in the errors towards the bottom of the screenshot there’s the one it claims is in roles.js, but to the left it mentioned Developer.developer_images.js - those are 2 completely different files? And it’s mentioning line 14 - line 14 is empty?

Any idea what is going on here?

Or has anyone been able to get imagemin in to their project working correctly?

Thanks