I am trying to map the max value of a slider to the number of pictures in a directory. I am trying to do that using fs-extra but I am not sure what I am doing wrong. I am getting errors when trying to import the function. I cannot download it through the terminal and I am working in a .html file.
Here is the code I am using.
<script type="module">
import fs from './node-fs-extra/lib/output-file/index.js';
// Use the fs module to read the contents of a directory
const directoryPath = '/path/to/directory';
const files = fs.readdirSync(directoryPath);
const imageFiles = files.filter(file => file.endsWith('.jpg') || file.endsWith('.png'));
const numImages = imageFiles.length;
// Set the maximum value of the slider to the number of images
const slider2 = document.getElementById('slider');
slider2.setAttribute('max', numImages);
</script>