Trouble Importing fs Module in JavaScript File to Read txt File. The js file is linked to HTML File

19 Views Asked by At

I'm encountering an issue while attempting to import the fs module in my JavaScript file to read a txt file, which I've linked to my HTML file. Despite my efforts, the JavaScript file fails to establish a link with the HTML file, preventing the successful execution of my file reading operations.

I have saved my javascript file as '.mjs' because it doesn't work at all with the normal '.js' extention

import fs from 'fs'

this is how i have imported the file

this is how I've linked it to my html file

    <script type="module"src="fileReadTest.mjs"></script>

and this is the error im getting on my dev console

enter image description here

0

There are 0 best solutions below