编译报错
情况1:
orionos-sh run 执行报错
error node_modules\@react-navigation\core\lib\module\views\NavigationContext.js: Property body[5] of BlockStatement expected node to be of a type [“Statement”] but instead got “AssignmentExpression”
debug TypeError: Property body[5] of BlockStatement expected node to be of a type [“Statement”] but instead got “AssignmentExpression”
[orionos-cli error]: Error: Command failed: node node_modules/react-native/local-cli/cli.js bundle –reset-cache –config platform.config.js –platform android –verbose –bundle-output ./bundle_output/publish/platform.android.bundle –entry-file ./platformIndex.js –dev false –assets-dest ./bundle_output/publish/res
Error: Command failed: orionos-cli pack –multiBundle false –extraEnable true –type plugin –buildVersion false –nlpAction true
解决方案:
- 环境问题,将package-lock.json和node_modules删除,重新下载
情况2(windows):
D:\phpstudy_pro\WWW\vue\weilirobotmini>orionos-sh run
Start run plugin opk
Error while accessing provider:com.ainirobot.robotplatform.dataprovider
android.database.sqlite.SQLiteException: unrecognized token: “\” (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM AppInfo WHERE (type=\’host\’)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:179)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
at com.android.commands.content.Content$QueryCommand.onExecute(Content.java:619)
at com.android.commands.content.Content$Command.execute(Content.java:470)
at com.android.commands.content.Content.main(Content.java:690)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:340)
TypeError: Cannot read property ‘split’ of undefined
at queryOPKInfo (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\src\utils\OPKUtils.js:121:25)
at runPlugin (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\src\run\run.js:292:20)
at run (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\src\run\run.js:436:13)
at Command.<anonymous> (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\src\index.js:51:13)
at Command.listener (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\node_modules\commander\index.js:315:8)
at Command.emit (events.js:209:13)
at Command.parseArgs (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\node_modules\commander\index.js:651:12)
at Command.parse (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\node_modules\commander\index.js:474:21)
at Object.<anonymous> (C:\Users\86159\AppData\Roaming\nvm\v12.10.0\node_modules\orionos-sh\src\index.js:110:9)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11
Error: 当前机器未安装Workflow,不支持插件型OPK。
解决方案:
- 命令行:adb shell content query –uri content://com.ainirobot.robotplatform.dataprovider/AppInfo –where “type=\’host\'” (不正常,原因可能是windows电脑造成的,建议下载Windows terminal 新版本再次尝试)
- 或者修改node_modules\orionos-sh\src\utils\OPKUtils.js 文件 +95行,把type=\’host\'” 改位type=’host'”
情况3:
error node_modules/react-native-webview/lib/WebView.android.js: Unexpected token: operator (<) in file node_modules/react-native-webview/lib/WebView.android.js at 368:20
debug Error: Unexpected token: operator (<) in file node_modules/react-native-webview/lib/WebView.android.js at 368:20
at /Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:414:17
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:75:24)
at _next (/Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:95:9)
at /Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:100:7
at new Promise (<anonymous>)
at /Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:92:12
at JsTransformer._minifyCode (/Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:421:7)
at /Users/sakuya/Desktop/hgx_normal_v2/node_modules/metro/src/JSTransformer/worker.js:355:33
[orionos-cli error]: Error: Command failed: node node_modules/react-native/local-cli/cli.js bundle –reset-cache –config platform.config.js –platform android –verbose –bundle-output ./bundle_output/publish/platform.android.bundle –entry-file ./platformIndex.js –dev false –assets-dest ./bundle_output/publish/res
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at doBuildPluginBundle (/Users/sakuya/.orionos-cli/dist/commands/pack/build.js:8:6178)
at build (/Users/sakuya/.orionos-cli/dist/commands/pack/build.js:12:143)
at Timeout._onTimeout (/Users/sakuya/.orionos-cli/dist/commands/pack/localPack.js:16:4)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
Error: Command failed: orionos-cli pack –multiBundle false –extraEnable true –type plugin –buildVersion false –nlpAction true
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at pack (/usr/local/lib/node_modules/orionos-sh/src/pack/pack.js:70:5)
at Command.<anonymous> (/usr/local/lib/node_modules/orionos-sh/src/index.js:33:13)
at Command.listener (/usr/local/lib/node_modules/orionos-sh/node_modules/commander/index.js:315:8)
at Command.emit (events.js:203:13)
at Command.parseArgs (/usr/local/lib/node_modules/orionos-sh/node_modules/commander/index.js:651:12)
at Command.parse (/usr/local/lib/node_modules/orionos-sh/node_modules/commander/index.js:474:21)
at Object.<anonymous> (/usr/local/lib/node_modules/orionos-sh/src/index.js:110:9)
at Module._compile (internal/modules/cjs/loader.js:868:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)
at Module.load (internal/modules/cjs/loader.js:731:32)
at Function.Module._load (internal/modules/cjs/loader.js:644:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)
at internal/main/run_main_module.js:17:11
解决方案:
- 调整package.json文件:
- 找到 “metro-react-native-babel-preset”: “0.53.1”, 更改为如下版本:
- “metro-react-native-babel-preset”: “0.66.0”,
- 这是插件和本机环境版本兼容性问题,修改即可。
情况4:
orionos-sh run 执行报错
解决方案:
修改项目根目录下的.npmrc 文件,补全用户名和邮箱,
registry = https://npm.ainirobot.com/repository/eve-group/
init.author.name=
init.author.email=
init.author.url = https://npm.ainirobot.com
init.author.password =
# an email is required to publish npm packages
email=
情况5:
cmd.option(opt.name, opt.description ?? ”, opt.parse || (val => val), typeof opt.default === ‘function’ ? opt.default(config) : opt.default);
解决方案:
将 package.json 中的@types的库去掉
情况6:
提示找不到acorn库,在dependencies依赖里增加:”acorn”: “8.8.2”