here i want to use fs library at the js file to create and edit a json file. but whenever i include this namespace an strange error comes up. if i use
var fs = require("fs")
it throws the error:
Uncaught ReferenceError: require is not defined
if i use (in terms of any order)
import fs from "fs"
then it throws
Uncaught SyntaxError: import declarations may only appear at top level of a module
i even have tried using the require.js file but in that case it throws those errors:
Uncaught Error: Module name "fs" has not been loaded yet for context: _. Use require([])
now if i use require(["fs"])
it says:
Uncaught SyntaxError: expected expression, got '<'
and a few seconds later
Uncaught Error: Load timeout for modules: fs
i even have tried to create another js file in the separate folder and use the require in that too but it still doesn't work.