HarmonyOS鸿蒙Next中引入ramdajs ArkTS:ERROR Failed to resolve OhmUrl

HarmonyOS鸿蒙Next中引入ramdajs ArkTS:ERROR Failed to resolve OhmUrl 1 在项目根目录建立ramda文件夹(编译后的代码 + oh-package.json5)

  • 项目路径 /Volumes/work/DevEcoStudioProjects/MyApplication/ramda
{
  "name": "ramda",
  "version": "0.32.0",
  "main": "./index.js",
  "type":"module"
}

index.js文件内容

export { default as add } from "./add.js";
import _curry2 from "./internal/_curry2.js";

/**
 * Adds two values.
 *
 * @func
 * @memberOf R
 * @since v0.1.0
 * @category Math
 * @sig Number -> Number -> Number
 * @param {Number} a
 * @param {Number} b
 * @return {Number}
 * @see R.subtract
 * @example
 *
 *      R.add(2, 3);       //=>  5
 *      R.add(7)(10);      //=> 17
 */
var add = /*#__PURE__*/_curry2(function add(a, b) {
  return Number(a) + Number(b);
});
export default add;

cke_3755.png

/Volumes/work/DevEcoStudioProjects/MyApplication/entry/oh-package.json5

{
  "name": "entry",
  "version": "1.0.0",
  "description": "Please describe the basic information.",
  "main": "",
  "author": "",
  "license": "",
  "dependencies": {
    "ramda": "file:../ramda" // 路径根据实际工程结构调整
  }
}

hvigor ERROR: Failed :entry:default@CompileArkTS

hvigor ERROR: 10311009 ArkTS: ERROR

Error Message: Failed to execute es2abc.

  • Try the following:

    Please refer to es2abc’s error codes.

1 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js” imported by “/Volumes/work/DevEcoStudioProjects/MyApplication/entry/src/main/ets/pages/Index.ets”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js” is correct(including case-sensitivity).

2 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js” imported by “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js” is correct(including case-sensitivity).

3 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js” imported by “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js” is correct(including case-sensitivity).

4 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js” imported by “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js” is correct(including case-sensitivity).

5 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js” imported by “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js” is correct(including case-sensitivity).

6 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js” imported by “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js” is correct(including case-sensitivity).

7 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js” imported by “undefined”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/index.js” is correct(including case-sensitivity).

8 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js” imported by “undefined”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/add.js” is correct(including case-sensitivity).

9 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js” imported by “undefined”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry2.js” is correct(including case-sensitivity).

10 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js” imported by “undefined”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_curry1.js” is correct(including case-sensitivity).

11 ERROR: 10311002 ArkTS: ERROR

Error Message: Failed to resolve OhmUrl. Failed to get a resolved OhmUrl for “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js” imported by “undefined”.

  • Try the following:

    Check whether the “undefined” module which /Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js belongs to is correctly configured.

    Check if the corresponding file name “/Volumes/work/DevEcoStudioProjects/MyApplication/ramda/internal/_isPlaceholder.js” is correct(including case-sensitivity).

12 ERROR: Error Message: Failed to emit /Volumes/work/DevEcoStudioProjects/MyApplication/entry/build/default/intermediates/loader_out/default/ets/modules.abc, error: Field {undefined.scopeNames} has different value.

If you’re using any cache file generated by older version of SDK, please try cleaning the cache files and rebuild

GenerateProgram Failed!

COMPILE RESULT:FAIL {ERROR:13}

  • Try:

Run with --stacktrace option to get the stack trace.

Run with --debug option to get more log output.


更多关于HarmonyOS鸿蒙Next中引入ramdajs ArkTS:ERROR Failed to resolve OhmUrl的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

更多关于HarmonyOS鸿蒙Next中引入ramdajs ArkTS:ERROR Failed to resolve OhmUrl的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS鸿蒙Next中,ramdajs库依赖OhmUrl模块。该错误表明项目配置中缺少OhmUrl依赖或路径解析失败。请检查项目的oh-package.json文件,确认是否正确定义了OhmUrl依赖项及版本。若使用DevEco Studio,需验证依赖是否成功同步至node_modules目录。确保所有必需的模块声明完整且符合HarmonyOS模块规范。

这个错误是因为在HarmonyOS Next中,ArkTS编译器无法正确解析ramda库的模块路径。主要问题在于:

  1. 模块类型不匹配:ramda的package.json中设置了"type":"module",但ArkTS目前对ES模块的支持有限,建议改为CommonJS格式。

  2. 文件扩展名问题:在ArkTS中,导入ES模块需要明确指定.js扩展名,但ramda内部的相对导入可能缺少扩展名。

  3. 模块解析机制:ArkTS的Ohm模块系统对第三方JavaScript库的解析支持还不够完善。

解决方案

  • 将ramda的package.json中的"type":"module"移除
  • 确保所有导入语句都包含完整的文件扩展名
  • 考虑使用已经适配HarmonyOS的TypeScript版本ramda,或者寻找替代的函数式编程库

目前HarmonyOS Next对纯ES模块格式的第三方JavaScript库支持还不够稳定,建议等待后续SDK版本的改进。

回到顶部