Pluggable widget : Error fs.writeFile is not a function TypeError: fs.writeFile is not a function

0
Hi guys, Studio Pro : 9.4 I am implementing a pluggable widget . I am trying to use some node modules like fs , node-7z . I have written a basic code to update text in a file. I am using following codes  Test3.js const fs1 = require("../../node_modules/fs"); exports.myTest = () => {     console.log("Test 3");     console.log("test 333333333333---------------!");     fs1.writeFile("D:/Vijayakumar/WriteFromCustomWidget.txt", "hh"); }; and I am importing that module into this Jsx file.  import { Component, createElement } from "react"; import { myTest } from "./Test3"; export class BadgeSample extends Component { constructor() { super(); this.myTest=myTest(); } render() { return <span>Test......!</span>; } }   When build this widget using “npm run build” there is no error showing. From Studio pro I’ve synchronized file system and cleaned the deployment directory→ then run locally. when open app from browser it shows error as follows, fs1.writeFile is not a function TypeError: fs1.writeFile is not a function at myTest (http://localhost:8081/widgets/siemens/myfifthwidget/MyFifthWidget.js?637666126638679133:29:8) at new BadgeSample (http://localhost:8081/widgets/siemens/myfifthwidget/MyFifthWidget.js?637666126638679133:1425:20) at mo (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:49377) at za (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:68776) at Us (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:112246) at Sc (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:98397) at _c (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:98325) at xc (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:98188) at fc (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:95175) at cc (http://localhost:8081/mxclientsystem/mxui/mxui.js?637666126638679133:46:92525)   anyone having idea on this issue , what i did wrong ? pls suggest your feedback to resolve this issue. One more issue have faced is ,  Error: 'fs' is imported by fs?commonjs-external, but could not be resolved – treating it as an external dependency like this ( for fs, path, assert, stream ) whatever has some others dependencies  that is also showing error and unable to build the widget. Please guide me, how to use node modules in our Custom/ Pluggable widget implementation. If any one used node modules pls give me the sample code. it will be more helpful to understand.
asked
0 answers