import * as fs from "fs";
const image1 = Media.addImage(document, fs.readFileSync("new.png"));
Here is the configuration from my tsconfig.json:
"compileOnSave": false,
"compilerOptions": {
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": false,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"module": "commonjs",
},
"include": [
"src/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}
I am using the fs module to add an image file in my word document with Docx, you can find more information here.
Unfortunately, I encountered an error while trying to import. Can someone provide me with a solution?
Error: ERROR TypeError: fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync is not a function