Monday, 17 August 2020

"ReferenceError: require is not defined"

Using a Node.js module called "fs-extra" (for working with file systems) a javascript, App.js works as expected when called from a terminal via this command: "Node App.js" When the app is accessed via a browser and an HTML file, an error is reported "ReferenceError: require is not defined" The git-hub repo for fs-extra instructs one to use this line of code "const fs = require('fs-extra')" Is this normal? Also, if one cannot use of this in a browser what s the usefulness of Node.js?const fs = require('fs-extra'); function onBUT_CLICK() { var sample = "3.14159265357989 ...." console.log(sample + "<----this"); fs.appendFileSync('output.txt', sample); } onBUTTON_CLICK()

Submitted August 17, 2020 at 01:18PM by pastaMac

No comments:

Post a Comment