vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.17k stars 6.15k forks source link

[plugin:vite:json] Failed to parse JSON file. #5106

Closed JohnnyLuv closed 3 years ago

JohnnyLuv commented 3 years ago

Describe the bug

I was created the vite2 project from create-react-app project, the code is working on the CRA project, but I got the error message on the vite2 project.

the json file named geo.json that be used to echarts map, and the json file is so big much.

however, I was rename the json file to geo.js, and write export default before the file begin, its working~

Reproduction

image

System Info

### system
macOS Big Sur v11.6

### binaries
apple m1

### browsers
google chrome v93.0.4577.82

Used Package Manager

yarn

Logs

下午4:55:41 [vite] Internal server error: Failed to parse JSON file.
  Plugin: vite:json
  File: /Users/xxx/web/src/assets/mock/china.geo.v3.json
      at formatError (/Users/xxx/web/node_modules/vite/dist/node/chunks/dep-36bf480c.js:50163:46)
      at TransformContext.error (/Users/xxx/web/node_modules/vite/dist/node/chunks/dep-36bf480c.js:50159:19)
      at TransformContext.transform (/Users/xxx/web/node_modules/vite/dist/node/chunks/dep-36bf480c.js:75770:22)
      at Object.transform (/Users/xxx/web/node_modules/vite/dist/node/chunks/dep-36bf480c.js:50373:53)
      at async transformRequest (/Users/xxx/web/node_modules/vite/dist/node/chunks/dep-36bf480c.js:65414:29)
      at async viteTransformMiddleware (/Users/xxx/web/node_modules/vite/dist/node/chunks/dep-36bf480c.js:65542:32)

Validations

github-actions[bot] commented 3 years ago

Hello @JohnnyLuv. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

JohnnyLuv commented 3 years ago

gogogo~