HarmonyOS鸿蒙Next中ERROR: internal/modules/cjs/loader.js:888
HarmonyOS鸿蒙Next中ERROR: internal/modules/cjs/loader.js:888 安装三方库,DevEco Studio报错
操作步骤:
- DevEco Studio打开终端,输入
ohpm install @ohasasugar/hp-richtext
- 报错
Mon Sep 9 13:52:38 CST 2024
[13:52:40] [~/Desktop/MyApplication/entry/src/main/ets/pages] ❱❱❱ ohpm install @ohasasugar/hp-richtext
-e ERROR: internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module 'node:url'
Require stack:
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/node_modules/glob/dist/commonjs/glob.js
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/node_modules/glob/dist/commonjs/index.js
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/core/missing-dep-detect/DepStatementsMissingDetector.js
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/core/publish/PublishCore.js
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/commands/publish.js
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/index.js
- /Applications/DevEco-Studio.app/Contents/tools/ohpm/bin/pm-cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Applications/DevEco-Studio.app/Contents/tools/ohpm/node_modules/glob/dist/commonjs/glob.js:5:20)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/node_modules/glob/dist/commonjs/glob.js',
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/node_modules/glob/dist/commonjs/index.js',
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/core/missing-dep-detect/DepStatementsMissingDetector.js',
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/core/publish/PublishCore.js',
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/commands/publish.js',
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/lib/index.js',
'/Applications/DevEco-Studio.app/Contents/tools/ohpm/bin/pm-cli.js'
]
}
更多关于HarmonyOS鸿蒙Next中ERROR: internal/modules/cjs/loader.js:888的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
这边测试下载该三方库没问题,重启电脑然后重新新建一个项目安装该三方库测试一下
更多关于HarmonyOS鸿蒙Next中ERROR: internal/modules/cjs/loader.js:888的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中出现ERROR: internal/modules/cjs/loader.js:888
错误,通常与Node.js模块加载问题相关。可能原因包括:
- 模块路径错误:确保模块路径正确,检查
require
或import
语句。 - 模块未安装:运行
npm install
或yarn install
安装缺失的依赖。 - Node.js版本不兼容:检查Node.js版本是否与项目要求匹配,必要时升级或降级。
- 缓存问题:尝试清除Node.js缓存,执行
npm cache clean --force
。
确保开发环境配置正确,并检查相关配置文件。