创建mudole ets/index 添加export导出 export { HomePage } from './pages/HomePage'
报错 :Cannot find module 'home' or its corresponding type declarations. <tsCheck>
module.json5
{
"module": {
"name": "home",
"type": "shared",
"description": "$string:shared_desc",
"deviceTypes": [
"phone",
"tablet"
],
"deliveryWithInstall": true,
"pages": "$profile:main_pages"
}
}
hvigorfile.ts
module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks
build-profile.json5
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"name": "home",
"srcPath": "./home",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
oh-package.json5
{
"name": "entry",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"home": "file:../home"
}
}
当 import { HomePage } from 'home'
时先去entry模块下的oh-package.json5 下去找对应模块
需要添加"common": "file:../home"
不然会报错Cannot find module 'home' or its corresponding type declarations. <tsCheck>