HarmonyOS鸿蒙Next中xts门禁编译报错hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript)
HarmonyOS鸿蒙Next中xts门禁编译报错hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript)
xts门禁编译报错hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript),Api版本:18,加了
"properties":
{
"ohos.nativeResolver":false
}
也不行
更多关于HarmonyOS鸿蒙Next中xts门禁编译报错hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript)的实战教程也可以访问 https://www.itying.com/category-93-b0.html
参考一下这个论坛的方案,https://developer.huawei.com/consumer/cn/forum/topic/0204128187014733530?fid=0102683795438680754;
看下是否有异常具体位置日志,提供最新demo方便定位分析
他这个还没有错误文件,
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [1/1] Hvigor info: > hvigor Finished :entry:ohosTest@CacheNativeLibs... after 2 ms
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [1/1] Hvigor info: > hvigor Finished :entry:ohosTest@SyscapTransform... after 404 ms
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [2/2] Hvigor warning: > hvigor ERROR: Failed :entry:ohosTest@OhosTestCompileArkTS...
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [2/2] Hvigor warning: > hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript)
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [2/2] Hvigor warning: ***//harmony_code/codearts_workspace/test/xts/acts/commonlibrary/ets_utils/concurrent_test/taskpoolandtimer/entry/src/ohosTest/ets/workers/Worker1.ets:16
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [2/2] Hvigor warning: WARN: ArkTS:WARN File: ***//harmony_code/codearts_workspace/test/xts/acts/commonlibrary/ets_utils/concurrent_test/taskpoolandtimer/oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/index.ets:27:20
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [2/2] Hvigor warning: Use explicit types instead of "any", "unknown" (arkts-no-any-unknown)
2025-03-17 15:35:36: [OHOS INFO] [NINJA] [2/2] Hvigor warning:
在HarmonyOS鸿蒙Next中,xts门禁编译报错hvigor ERROR: Unexpected token (Note that you need plugins to import files that are not JavaScript)通常是由于项目配置或依赖问题导致的。具体原因可能包括:
-
文件类型不匹配:hvigor在编译时遇到了非JavaScript文件,但没有相应的插件来处理这些文件。确保项目中所有导入的文件类型都正确,并安装了相应的插件。
-
插件缺失:hvigor需要特定的插件来解析非JavaScript文件。检查
hvigor配置文件(如hvigorfile.js),确保已安装并配置了所有必要的插件。 -
依赖版本不兼容:某些依赖库或插件版本可能与当前hvigor版本不兼容。检查项目依赖项,确保所有依赖库和插件的版本都是兼容的。
-
配置文件错误:
hvigorfile.js或其他配置文件可能存在语法错误或不正确的配置。仔细检查这些文件,确保没有错误。 -
路径问题:文件路径可能不正确,导致hvigor无法找到或正确解析文件。检查相关文件的路径,确保它们在项目中正确引用。
解决此问题的步骤包括检查项目配置文件、确保所有必要插件已安装并正确配置、验证依赖版本兼容性以及检查文件路径是否正确。
在HarmonyOS鸿蒙Next中,xts门禁编译报错hvigor ERROR: Unexpected token通常是由于项目中引入了非JavaScript文件(如TypeScript、JSON等),但未配置相应插件导致。建议检查hvigor配置文件,确保已安装并启用了必要的插件(如@babel/plugin-transform-typescript)。同时,确认文件扩展名和解析规则是否正确配置。


