rwjblue / git-repo-info

MIT License
112 stars 28 forks source link

React Error : TypeError: fs.existsSync is not a function #41

Open rlembo06 opened 5 years ago

rlembo06 commented 5 years ago

Hi, when import your package on React project, i receive this error capture du 2018-11-17 14-07-57

rwjblue commented 5 years ago

Hey @rlembo06, thanks for opening an issue! This library requires access to the filesystem which wouldn't normally be available in the browser like this. The specific error is likely due to the fs shim not being able to cover all aspects of fs (since its running in browser).

Maybe you could describe what you are trying to do?

larrym commented 5 years ago

I have the same issue. I am trying to embed git info in a React module. I used create-react-app to begin this project.

const someModule = () => {
   ...
      <h5>{gitInfo()}</h5>
   ...
    const gitInfo = () => {
      const info = getRepoInfo();
      return `${info.tag}-${info.abbreviatedSha}-${info.authorDate}`;
    };
}

export default someModule;