Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法启动前端功能 #4

Closed
Micro-sheep opened this issue Dec 12, 2022 · 6 comments
Closed

无法启动前端功能 #4

Micro-sheep opened this issue Dec 12, 2022 · 6 comments
Labels
question Further information is requested

Comments

@Micro-sheep
Copy link

环境: vite/3.2.4 linux-x64 node-v19.2.0

具体错误

$ npm run dev

> web@0.0.0 dev
> vite

✘ [ERROR] Unexpected end of file in JSON

    ../../package.json:1:0:
      1 │
        ╵ ^

failed to load config from /home/sheep/crm/web/vite.config.js
error when starting dev server:
Error: Build failed with 1 error:
../../package.json:1:0: ERROR: Unexpected end of file in JSON
    at failureErrorWithLog (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:1566:15)
    at /home/sheep/crm/web/node_modules/esbuild/lib/main.js:1024:28
    at runOnEndCallbacks (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:1438:61)
    at buildResponseToResult (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:1022:7)
    at /home/sheep/crm/web/node_modules/esbuild/lib/main.js:1134:14
    at responseCallbacks.<computed> (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:671:9)
    at handleIncomingPacket (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:647:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)

拉取最新的代码来跑的,没有做任何修改。

@zchengo
Copy link
Owner

zchengo commented Dec 13, 2022

删除 node_modules 目录,重新 npm install 试试

@Micro-sheep
Copy link
Author

删除 node_modules 目录,重新 npm install 试试

删除了,还是没法运行。操作如下。

# sheep @ server in ~/crm/web on git:main x [11:00:26]
$ rm -rf node_modules

# sheep @ server in ~/crm/web on git:main x [11:00:30]
$

# sheep @ server in ~/crm/web on git:main x [11:00:31]
$ npm install

added 96 packages in 7s

# sheep @ server in ~/crm/web on git:main x [11:00:41]
$ npm run dev

> web@0.0.0 dev
> vite

✘ [ERROR] Unexpected end of file in JSON

    ../../package.json:1:0:
      1 │
        ╵ ^

failed to load config from /home/sheep/crm/web/vite.config.js
error when starting dev server:
Error: Build failed with 1 error:
../../package.json:1:0: ERROR: Unexpected end of file in JSON
    at failureErrorWithLog (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:1566:15)
    at /home/sheep/crm/web/node_modules/esbuild/lib/main.js:1024:28
    at runOnEndCallbacks (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:1438:61)
    at buildResponseToResult (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:1022:7)
    at /home/sheep/crm/web/node_modules/esbuild/lib/main.js:1134:14
    at responseCallbacks.<computed> (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:671:9)
    at handleIncomingPacket (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/home/sheep/crm/web/node_modules/esbuild/lib/main.js:647:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)

@zchengo
Copy link
Owner

zchengo commented Dec 13, 2022

检查一下你的 node 版本,是不是 >= 18.12.0

@Micro-sheep
Copy link
Author

检查一下你的 node 版本,是不是 >= 18.12.0

node 版本是 19.2.0,按你说的换源也是会在 npm run dev 出错。

@zchengo
Copy link
Owner

zchengo commented Dec 13, 2022

还有一个办法就是,你 node 版本降到 18.12.0 ,我电脑用的 node 是这个版本的,执行 npm run dev 是没问题的

@Micro-sheep
Copy link
Author

还有一个办法就是,你 node 版本降到 18.12.0 ,我电脑用的 node 是这个版本的,执行 npm run dev 是没问题的

已解决,解决方法是把用户根目录下面的 package.json 删掉。

@zchengo zchengo closed this as completed Dec 24, 2022
@zchengo zchengo reopened this Dec 24, 2022
@zchengo zchengo added the question Further information is requested label Dec 24, 2022
@zchengo zchengo closed this as completed Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants