-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Description
请先确认
- 我已搜索并确定这个提交不是重复的
Taro 版本
v4
相关平台
- 所有平台
- Web 端(H5)
- 移动端(React-Native)
- 鸿蒙(Harmony)
- 鸿蒙容器(Harmony Hybrid)
- ASCF 元服务
- 快应用(QuickApp)
- 所有小程序
- 微信小程序
- 企业微信小程序
- 京东小程序
- 百度小程序
- 支付宝小程序
- 支付宝 IOT 小程序
- 头条小程序
- QQ 小程序
- 钉钉小程序
- 飞书小程序
- 快手小程序
小程序基础库版本
1
使用框架
React
问题描述
新建项目,编译鸿蒙报错
D:\project\git\3.0\node_modules@tarojs\plugin-platform-harmony-cpp\dist\index.js:177
const businessId = platform.getConfig().defineConstants?.LOCATION_APIKEY?.replace(/^['"]|['"]$/g, '');
^
TypeError: platform.getConfig is not a function
at Harmony.injectEnv (D:\project\git\3.0\node_modules@tarojs\plugin-platform-harmony-cpp\dist\index.js:177:33)
at Object.fn (D:\project\git\3.0\node_modules@tarojs\plugin-platform-harmony-cpp\dist\index.js:1173:197)
at Kernel. (D:\project\git\3.0\node_modules@tarojs\service\src\Kernel.ts:307:34)
at Generator.next ()
at D:\project\git\3.0\node_modules@tarojs\service\dist\Kernel.js:8:71
at new Promise ()
at __awaiter (D:\project\git\3.0\node_modules@tarojs\service\dist\Kernel.js:4:12)
at D:\project\git\3.0\node_modules@tarojs\service\src\Kernel.ts:306:24
at eval (eval at create (D:\project\git\3.0\node_modules\tapable\lib\HookCodeFactory.js:75:10), :33:17)
at new Promise ()
复现链接
https://github.com/fanlvwen/taro4.1.1-harmony/blob/main/git-hm-taro412.zip
复现步骤
1.直接运行复现链接https://github.com/fanlvwen/taro4.1.1-harmony/blob/main/git-hm-taro412.zip,yarn build:hm
2.报错如问题描述
3.定位到对应代码,打印platform信息如下
{
viteConfig: { plugins: [ [Array], [Array], [Object], [Array], [Array] ] },
data: {
componentConfig: {
includes: [Set],
exclude: Set(0) {},
thirdPartyComponents: Map(0) {},
includeAll: false
}
},
viteCompilerContext: TaroCompilerContext {
logger: {
info: [Function: info],
warn: [Function: warn],
error: [Function: error]
},
filesConfig: {
'app.config': [Object],
'taro-pages/index/CarRentalIndex.config': [Object],
'taro-pages/index/OrderCenter.config': [Object],
'taro-pages/redPacket/RedPackageListTab.config': [Object],
'taro-pages/index/AutomatedQuestions.config': [Object],
'taro-pages/surrogate/indexJd.config': [Object],
'taro-pages/surrogate/indexQcp.config': [Object],
'taro-pages/index/WxPay.config': [Object]
},
configFileList: [
'D:\project\git\3.0\src\taro-pages\index\CarRentalIndex.config.js',
'D:\project\git\3.0\src\taro-pages\index\OrderCenter.config.jsx',
'D:\project\git\3.0\src\taro-pages\redPacket\RedPackageListTab.config.jsx',
'D:\project\git\3.0\src\taro-pages\index\AutomatedQuestions.config.js',
'D:\project\git\3.0\src\taro-pages\surrogate\indexJd.config',
'D:\project\git\3.0\src\taro-pages\surrogate\indexQcp.config',
'D:\project\git\3.0\src\taro-pages\index\WxPay.config.js'
],
cwd: 'D:\project\git\3.0',
rawTaroConfig: {
entry: [Object],
alias: [Object],
copy: [Object],
sourceRoot: 'src',
outputRoot: 'D:\project\git\hmDemo\hm-0529\entry\src\main\ets',
platform: 'harmony_cpp',
framework: 'react',
compiler: [Object],
cache: [Object],
logger: undefined,
baseLevel: undefined,
csso: undefined,
sass: undefined,
uglify: undefined,
plugins: [Array],
projectName: 'taroDemo',
env: [Object],
defineConstants: {},
designWidth: [Function: designWidth],
deviceRatio: [Object],
projectConfigName: undefined,
jsMinimizer: undefined,
cssMinimizer: undefined,
terser: undefined,
esbuild: undefined,
projectPath: 'D:\project\git\hmDemo\hm-0529',
hapName: 'entry',
ohpm: 'D:\ohpm\bin\ohpm',
iconFontPath: './assets/fonts/iconfont.ttf',
iconFontName: 'iconfont',
ohPackage: [Object],
chorePackagePrefix: '@taro-oh/library/src/main/ets/npm',
harmony: [Object],
isWatch: false,
mode: 'production',
blended: false,
isBuildNativeComp: false,
withoutBuild: false,
newBlended: false,
noInjectGlobalStyle: false,
modifyAppConfig: [Function: modifyAppConfig],
modifyWebpackChain: [Function: modifyWebpackChain],
modifyViteConfig: [Function: modifyViteConfig],
modifyBuildAssets: [Function: modifyBuildAssets],
modifyMiniConfigs: [Function: modifyMiniConfigs],
modifyComponentConfig: [Function: modifyComponentConfig],
onCompilerMake: [Function: onCompilerMake],
onParseCreateElement: [Function: onParseCreateElement],
onBuildFinish: [Function: onBuildFinish],
buildAdapter: 'harmony_cpp',
fileType: [Object],
platformType: 'harmony',
useETS: true,
useJSON5: true,
isPure: false,
runtimePath: '@tarojs/plugin-platform-harmony-cpp/dist/runtime/runtime-harmony',
taroComponentsPath: '@tarojs/plugin-platform-harmony-ets/dist/components-harmony-ets'
},
taroConfig: {
sourceRoot: 'src',
fileType: [Object],
imageUrlLoaderOption: [Object],
fontUrlLoaderOption: [Object],
mediaUrlLoaderOption: [Object],
postcss: [Object],
entry: [Object],
alias: [Object],
copy: [Object],
outputRoot: 'D:\project\git\hmDemo\hm-0529\entry\src\main\ets',
platform: 'harmony_cpp',
framework: 'react',
compiler: [Object],
cache: [Object],
logger: undefined,
baseLevel: undefined,
csso: undefined,
sass: undefined,
uglify: undefined,
plugins: [Array],
projectName: 'taroDemo',
env: [Object],
defineConstants: {},
designWidth: [Function: designWidth],
deviceRatio: [Object],
projectConfigName: undefined,
jsMinimizer: undefined,
cssMinimizer: undefined,
terser: undefined,
esbuild: undefined,
projectPath: 'D:\project\git\hmDemo\hm-0529',
hapName: 'entry',
ohpm: 'D:\ohpm\bin\ohpm',
iconFontPath: './assets/fonts/iconfont.ttf',
iconFontName: 'iconfont',
ohPackage: [Object],
chorePackagePrefix: '@taro-oh/library/src/main/ets/npm',
harmony: [Object],
isWatch: false,
mode: 'production',
blended: false,
isBuildNativeComp: false,
withoutBuild: false,
newBlended: false,
noInjectGlobalStyle: false,
modifyAppConfig: [Function: modifyAppConfig],
modifyWebpackChain: [Function: modifyWebpackChain],
modifyViteConfig: [Function: modifyViteConfig],
modifyBuildAssets: [Function: modifyBuildAssets],
modifyMiniConfigs: [Function: modifyMiniConfigs],
modifyComponentConfig: [Function: modifyComponentConfig],
onCompilerMake: [Function: onCompilerMake],
onParseCreateElement: [Function: onParseCreateElement],
onBuildFinish: [Function: onBuildFinish],
buildAdapter: 'harmony_cpp',
platformType: 'harmony',
useETS: true,
useJSON5: true,
isPure: false,
runtimePath: '@tarojs/plugin-platform-harmony-cpp/dist/runtime/runtime-harmony',
taroComponentsPath: '@tarojs/plugin-platform-harmony-ets/dist/components-harmony-ets'
},
sourceDir: 'D:\project\git\3.0\src',
frameworkExts: [ '.js', '.jsx', '.ts', '.tsx' ],
extraComponents: [],
nativeExt: [ '.ets' ],
nativeComponents: Map(0) {},
ohpmPackageList: [],
compilePage: [Function (anonymous)],
fileType: { style: '.css', config: '.json', script: '.js', templ: '.hml' },
useETS: true,
useJSON5: true,
commonChunks: [ 'runtime', 'vendors', 'taro', 'common' ],
app: {
name: 'app',
scriptPath: 'D:\project\git\3.0\src\app.ts',
configPath: 'D:\project\git\3.0\src\app.config.ts',
config: [Object],
isNative: false
},
pages: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
]
}
}
,其中并没有platform.getConfig()方法,以及platform.context,所以报错编译失败
环境信息
👽 Taro v4.1.4
Taro CLI 4.1.4 environment info:
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 18.20.4 - ~\AppData\Local\Temp\yarn--1753788347042-0.7282853696157161\node.CMD
Yarn: 1.22.22 - ~\AppData\Local\Temp\yarn--1753788347042-0.7282853696157161\yarn.CMD
npm: 10.7.0 - D:\nodejs\npm.CMD
npmPackages:
@tarojs/cli: 4.1.4 => 4.1.4
@tarojs/components: 4.1.4 => 4.1.4
@tarojs/helper: 4.1.4 => 4.1.4
@tarojs/plugin-framework-react: 4.1.4 => 4.1.4
@tarojs/plugin-html: 4.1.4 => 4.1.4
@tarojs/plugin-platform-alipay: 4.1.4 => 4.1.4
@tarojs/plugin-platform-h5: 4.1.4 => 4.1.4
@tarojs/plugin-platform-harmony-ets: 4.1.4 => 4.1.4
@tarojs/plugin-platform-harmony-hybrid: 4.1.4 => 4.1.4
@tarojs/plugin-platform-jd: 4.1.4 => 4.1.4
@tarojs/plugin-platform-qq: 4.1.4 => 4.1.4
@tarojs/plugin-platform-swan: 4.1.4 => 4.1.4
@tarojs/plugin-platform-tt: 4.1.4 => 4.1.4
@tarojs/plugin-platform-weapp: 4.1.4 => 4.1.4
@tarojs/plugin-react-devtools: 4.1.4 => 4.1.4
@tarojs/react: 4.1.4 => 4.1.4
@tarojs/rn-runner: 4.1.4 => 4.1.4
@tarojs/rn-supporter: 4.1.4 => 4.1.4
@tarojs/runtime: 4.1.4 => 4.1.4
@tarojs/runtime-rn: 4.1.4 => 4.1.4
@tarojs/shared: 4.1.4 => 4.1.4
@tarojs/taro: 4.1.4 => 4.1.4
@tarojs/taro-rn: 4.1.4 => 4.1.4
@tarojs/vite-runner: 4.1.4 => 4.1.4
@tarojs/webpack5-runner: 4.1.4 => 4.1.4
babel-preset-taro: 4.1.4 => 4.1.4
expo: ~50.0.0 => 50.0.21
react: 18.2.0 => 18.2.0
react-native: 0.73.1 => 0.73.1贡献代码
- 我愿意修复这个错误。请参考 (贡献指南)