Usinf pandoc in a react application

Viewed 41

I am trying to implement pandoc on a local site. Then my question is it possible to use Pandoc in a react application?

I tried by in the App.js file by typing this:

import './App.css';
import nodePandoc from 'node-pandoc';

let src = './TEST.docx';
 
// Arguments can be either a single String or in an Array
let args = '-f docx -t markdown -o ./markdown.md';
 
// Set your callback function
const callback = (err, result)=> {
 
  if (err) console.error('Oh Nos: ',err)
  return console.log(result), result
}
 
// Call pandoc
nodePandoc(src, args, callback);

function App() {


  return (
    <div className="App">
      <h1> .....</h1>
    </div>
  );
}

export default App;
´´´
However I get this errors: 

ERROR in ../../../../node_modules/node-pandoc/index.js 1:11-29
Module not found: Error: Can't resolve 'fs' in 'C:\Users\apinto2\node_modules\node-pandoc'

ERROR in ../../../../node_modules/node-pandoc/index.js 3:12-42
Module not found: Error: Can't resolve 'child_process' in 'C:\Users\apinto2\node_modules\node-pandoc'

webpack compiled with 2 errors and 1 warning

Thank you so much for your help !
1 Answers

Disclaimer, no real knowledge of what Pandoc is, but looks like its something that needs to be installed on the usersmachine and is a command line tool, if thats the case, you won't be able to run it directly on the users machine, but you could set up and orchestration layer (backend layer) with Pandoc installed that the user could make requests to and that machine would use Pandoc and return the result.

Related