CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2022-10-31
by cwtuan

Original Post

Original - Posted on 2022-10-31
by cwtuan



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Don't use `fs` in the `pages` directory, since next.js suppose that files in `pages` directory are running in browser environment.
You could put the util file which uses `fs` to other directory such as `/core`
Then `require` the util in `getStaticProps` which runs in node.js environment.
```tsx // /pages/myPage/index.tsx import View from './view'; export default View;
export async function getStaticProps() { const util = require('core/some-util-uses-fs').default; // getStaticProps runs in nodes const data = await util.getDataFromDisk(); return { props: { data, }, }; }
```
Don't use `fs` in the `pages` directory, since next.js suppose that files in `pages` directory are running in browser environment.
You could put the util file which uses `fs` to other directory such as `/core`
Then `require` the util in `getStaticProps` which runs in node.js environment.
```tsx // /pages/myPage/index.tsx import View from './view'; export default View;
export async function getStaticProps() { const util = require('core/some-util-uses-fs').default; // getStaticProps runs in nodes const data = await util.getDataFromDisk(); return { props: { data, }, }; }
```

        
Present in both answers; Present only in the new answer; Present only in the old answer;