HarmonyOS 鸿蒙Next DevEco Studio 3.1.0.501 新建项目 工程同步失败

发布于 1周前 作者 itying888 来自 鸿蒙OS

HarmonyOS 鸿蒙Next DevEco Studio 3.1.0.501 新建项目 工程同步失败

![1712065667185.jpg](https://alliance-communityfile-drcn.dbankcdn.com/FileServer/getFile/cmtybbs/102/082/105/0890086000102082105.20240402214824.89946580671660213682263588496937:50001231000000:2800:0E36146DAB999DB9CD255B65FB6926C10769010FC755F45B07E0817EC386B199.jpg)

完整日志logo:

0 verbose cli C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node.exe C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\bin\npm-cli.js
1 info using npm@8.19.3
2 info using node@v16.19.1
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\Administrator\.hvigor\wrapper\tools\.npmrc Completed in 0ms
10 timing config:load:project Completed in 3ms
11 timing config:load:file:C:\Users\Administrator\.npmrc Completed in 2ms
12 timing config:load:user Completed in 2ms
13 timing config:load:file:C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 13ms
19 timing npm:load:configload Completed in 13ms
20 timing npm:load:mkdirpcache Completed in 1ms
21 timing npm:load:mkdirplogs Completed in 0ms
22 verbose title npm install
23 verbose argv "install" "--progress" "false" "--fetch-retry-mintimeout" "10000" "--fetch-retry-maxtimeout" "15000" "--fetch-retries" "1"
24 timing npm:load:setTitle Completed in 2ms
25 timing config:load:flatten Completed in 2ms
26 timing npm:load:display Completed in 3ms
27 verbose logfile logs-max:10 dir:C:\Users\Administrator\AppData\Local\npm-cache\_logs
28 verbose logfile C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-04-02T13_40_39_391Z-debug-0.log
29 timing npm:load:logFile Completed in 4ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 25ms
33 timing arborist:ctor Completed in 1ms
34 silly logfile done cleaning log files
35 timing idealTree Completed in 1ms
36 timing command:install Completed in 7ms
37 verbose stack JSONParseError: Unexpected token "\u0000" (0x00) in JSON at position 0 while parsing near "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000..."
37 verbose stack     at C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\node_modules\read-package-json-fast\index.js:11:61
37 verbose stack     at async Arborist.buildIdealTree (C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:208:7)
37 verbose stack     at async Promise.all (index 1)
37 verbose stack     at async Arborist.reify (C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:154:5)
37 verbose stack     at async Install.exec (C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\lib\commands\install.js:145:5)
37 verbose stack     at async module.exports (C:\Users\Administrator\AppData\Roaming\nvm\v16.19.1\node_modules\npm\lib\cli.js:78:5)
38 verbose cwd C:\Users\Administrator\.hvigor\wrapper\tools
39 verbose Windows_NT 10.0.16299
40 verbose node v16.19.1
41 verbose npm  v8.19.3
42 error code EJSONPARSE
43 error path C:\Users\Administrator\.hvigor\wrapper\tools/package.json
44 error JSON.parse Unexpected token "\u0000" (0x00) in JSON at position 0 while parsing near "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000..."
45 error JSON.parse Failed to parse JSON data.
45 error JSON.parse Note: package.json must be actual JSON, not just JavaScript.
46 verbose exit 1
47 timing npm Completed in 325ms
48 verbose unfinished npm timer reify 1712065239703
49 verbose unfinished npm timer reify:loadTrees 1712065239706
50 verbose unfinished npm timer idealTree:init 1712065239707
51 verbose code 1
52 error A complete log of this run can be found in:
52 error     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-04-02T13_40_39_391Z-debug-0.log

logo说,node v16.19.1 版本 read-package-json-fast\index.js 有问题,这个官方推荐版本啊
还有个在 .hvigor\wrapper\tools/package.json,这个 package 有问题。

不知道怎么解决了,有同情况吗

更多关于HarmonyOS 鸿蒙Next DevEco Studio 3.1.0.501 新建项目 工程同步失败的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

提工单解决问题了,.hvigor\wrapper\tools/package.json,这个生成的文件有问题,里面是空的,需要修改为

{"dependencies": {"pnpm": "7.30.0"}}

更多关于HarmonyOS 鸿蒙Next DevEco Studio 3.1.0.501 新建项目 工程同步失败的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


这是在window10上首次安装,安装了踩坑了

在HarmonyOS鸿蒙Next DevEco Studio 3.1.0.501中,新建项目后出现工程同步失败,可能是由于以下原因导致:

  1. 网络问题:网络连接不稳定或无法访问相关资源库,导致依赖项下载失败。
  2. Gradle配置问题:build.gradle文件中的依赖项或插件版本不兼容,或Gradle配置文件损坏。
  3. SDK或工具版本不匹配:DevEco Studio版本与鸿蒙SDK版本不兼容,或缺少必要的SDK组件。
  4. 代理设置问题:如果使用了代理,代理配置不正确可能导致同步失败。
  5. 缓存问题:Gradle缓存损坏或DevEco Studio缓存异常,影响工程同步。

解决方法:

  • 检查网络连接,确保可以访问相关资源。
  • 清理Gradle缓存,执行./gradlew cleanBuildCache
  • 更新DevEco Studio和鸿蒙SDK到最新版本。
  • 检查并修正build.gradle文件中的依赖项和插件版本。
  • 如果使用代理,确保代理配置正确。

如果问题仍未解决,可以尝试重新创建项目或查看DevEco Studio的日志文件以获取更多错误信息。

在HarmonyOS鸿蒙Next DevEco Studio 3.1.0.501中新建项目时遇到工程同步失败,可能原因包括网络问题、Gradle配置错误或SDK版本不兼容。建议检查网络连接,确保Gradle配置正确,并更新SDK至最新版本。如问题持续,尝试清理项目缓存或重新安装DevEco Studio。

回到顶部
AI 助手
你好,我是IT营的 AI 助手
您可以尝试点击下方的快捷入口开启体验!