question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

readFileSync is not a function

See original GitHub issue

When I am trying to use data: fs.readFileSync(“./demo/images/pizza.gif”) in Angular I get error message “readFileSync is not a function”

Thank you for raising an issue to docx

Please do not raise an issue unless it is an issue.

  • Is your issue a feature request? Are you giving ideas to the community? Are you asking for help? Please raise a ticket in the Discussions section:

    https://github.com/dolanmiu/docx/discussions

  • Is your issue a previously asked? Please respond to that thread instead

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
devoidfurycommented, May 27, 2021

No, it only does docx.

1reaction
devoidfurycommented, May 19, 2021

fs.readFileSync is a nodejs function. It doesn’t work in the browser.

If you’re trying to load an image in the browser, one way to do it is:

async function urlToBlob(url) {
  return (await fetch(url)).blob();
}

async function generateDocx() {
  // ...
  new ImageRun({
    data: await urlToBlob(url_of_image),
    // ...
  })
  //
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

readFileSync is not a function - Stack Overflow
This code will not run in the browser. Node.js runs on the server. If you want to load a JSON file on the...
Read more >
`_fsDefault.default.readFileSync is not a function` and file ...
readFileSync inlines text files correctly. fs.readFileSync stops working whenever the project is built on Linux.
Read more >
Node.js fs.readFileSync() Method - GeeksforGeeks
readFileSync () method is an inbuilt application programming interface of fs module which is used to read the file and return its content....
Read more >
Browserify-fs readFileSync is not a function
Uncaught TypeError : fs.readFileSync is not a function (4) You're using strings for the test and include loader options which won't match. These...
Read more >
Uncaught typeerror fs.readfilesync is not a function - help
js (outside any functions): import mapboxgl from 'mapbox-gl';. How can I get the npm package “mapbox-gl” to see the function fs.readfilesync? 1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found