Closed 8pig closed 7 months ago
DEBUG_TAG=app-config npm run start
看下详细的错误信息
@icedesign/stark-child@1.0.3 start ice start
⠋ loading config...› [BUILD-SCRIPTS] bundled module file loaded in 103m 10:44:53 › template render cost: 12 10:44:53 ⠴ loading config... ERROR Failed to get app config. 10:44:54
› Cannot find package 'react-dom' imported from /node_modules/.cache/default_defineAppConfig_app.mjs
at new NodeError (node:internal/errors:372:5)
at packageResolve (node:internal/modules/esm/resolve:954:9)
at moduleResolve (node:internal/modules/esm/resolve:1003:20)
at defaultResolve (node:internal/modules/esm/resolve:1218:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ModuleWrap.
TypeError: Cannot read properties of undefined (reading 'default')
at createService (node_modules/@ice/app/esm/createService.js:322:46)
at Command.
⠋ loading config...› [BUILD-SCRIPTS] bundled module file loaded in 103m 10:44:53 › template render cost: 12 10:44:53 ⠴ loading config... ERROR Failed to get app config. 10:44:54
› Cannot find package 'react-dom' imported from /node_modules/.cache/default_defineAppConfig_app.mjs
at new NodeError (node:internal/errors:372:5) at packageResolve (node:internal/modules/esm/resolve:954:9) at moduleResolve (node:internal/modules/esm/resolve:1003:20) at defaultResolve (node:internal/modules/esm/resolve:1218:11) at ESMLoader.resolve (node:internal/modules/esm/loader:580:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18) at ModuleWrap. (node:internal/modules/esm/module_job:80:40) at link (node:internal/modules/esm/module_job:78:36) /node_modules/@ice/app/esm/createService.js:322 const appConfig = (await getAppConfig()).default; ^
TypeError: Cannot read properties of undefined (reading 'default') at createService (node_modules/@ice/app/esm/createService.js:322:46) at Command. (/node_modules/@ice/app/bin/ice-cli.mjs:66:23)
"react": "^18.0.0",
提供下 src/app.ts 的代码和全量的 package.json 信息
提供下 src/app.ts 的代码和全量的 package.json 信息
app code
import { defineAppConfig } from 'ice';
import { defineChildConfig } from '@ice/plugin-icestark/types';
export * from './utils/service';
export const icestark = defineChildConfig(() => {
return {
mount: () => {
console.log('mount');
},
unmount: () => {
console.log('unmount');
},
};
});
export default defineAppConfig(() => ({
app: {
rootId: 'app',
},
}));
service.ts
export const requestConfig = defineRequestConfig({
// 可选的,全局设置 request 是否返回 response 对象,默认为 false
withFullResponse: false,
maxRedirects: 0,
baseURL: baseURL(),
// baseURL: `${process.env.ICE_BASE_API}/api`,
headers: {},
// ...RequestConfig 其他参数
// 拦截器
interceptors: {
request: {
onConfig: (config) => {
// 发送请求前:可以对 RequestConfig 做一些统一处理
config.headers = {
'x-apihub-token': getToken() ?? '',
};
return config;
},
onError: (error) => {
return Promise.reject(error);
},
},
response: {
onConfig: (response) => {
return response;
},
onError: (error) => {
// 请求出错:服务端返回错误状态码
console.log(error.response!.data);
console.log(error.response!.status);
console.log(error.response!.headers);
return Promise.reject(error);
},
},
},
});
{ "name": "@icedesign/stark-child", "version": "1.0.3", "description": "微前端方案 icestark 的子应用模板,用于快速初始化微应用", "homepage": "https://icestark-react.surge.sh/seller", "dependencies": { "@ahooksjs/use-url-state": "^3.5.1", "@ant-design/icons": "^4.7.0", "@ant-design/pro-components": "^2.5.5", "@ant-design/pro-form": "^2.2.8", "@ant-design/pro-layout": "^7.1.6", "@ant-design/pro-table": "^3.0.17", "@antv/g2": "5.1.5", "@ebay/nice-modal-react": "^1.2.10", "@ice/plugin-antd": "^1.0.1", "@ice/runtime": "^1.0.0", "@xxx/xxx-icons": "link:external/xxxx/xxx-icons", "@uiw/react-md-editor": "^3.25.6", "ahooks": "^3.7.8", "antd": "^5.10.2", "axios": "^1.4.0", "cross-env": "^7.0.3", "echarts": "^5.4.3", "echarts-for-react": "^3.0.2", "lodash": "^4.17.21", "moment": "^2.24.0", "postcss-nesting": "^11.2.2", "postcss-preset-env": "^8.4.2", "qs": "^6.11.2", "re-resizable": "^6.9.9", "react": "^18.0.0", "react-custom-scrollbars": "^4.2.1", "split-pane-react": "^0.1.3", "tailwindcss": "^3.3.2" }, "devDependencies": { "@applint/spec": "^1.2.3", "@arco-design/web-react": "^2.52.0", "@ice/app": "^3.0.0", "@ice/plugin-auth": "^1.0.1", "@ice/plugin-icestark": "^1.0.5", "@ice/plugin-request": "^1.0.1", "@ice/plugin-store": "^1.1.1", "@ice/stark-app": "^1.5.0", "@types/node": "^18.0.0", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", "autoprefixer": "^10.4.14", "clsx": "^1.2.1", "eslint": "^8.35.0", "postcss": "^8.4.24", "pubsub-js": "^1.9.4", "react-arborist": "3.2.0", "react-content-loader": "^6.2.1", "react-icons": "^4.6.0", "stylelint": "^15.2.0", "tree-model-improved": "^2.0.1", "typescript": "^4.8.4", "use-resize-observer": "^9.0.2" }, "scripts": { "start": "ice start", "dev": "cross-env LOCAL=LOCAL ice start", "build:dev": "ice build --mode development", "build:prod": "ice build --mode production", "eslint": "eslint ./src --cache --ext .js,.jsx,.ts,.tsx", "eslint:fix": "npm run eslint -- --fix", "stylelint": "stylelint \"src/*/.{css,scss,less}\" --cache", "stylelint:fix": "npm run stylelint -- --fix" }, "publishConfig": { "access": "public" }, "scaffoldConfig": { "name": "stark-child", "title": "icestark 子应用", "categories": [ "icestark" ], "screenshot": "https://img.alicdn.com/tfs/TB1X5.paYr1gK0jSZFDXXb9yVXa-2480-1200.png" }, "repository": { "type": "git", "url": "https://github.com/ice-lab/react-materials/tree/master/scaffolds/icestark-child" } }
package.json 中没有 react-dom 的依赖?
package.json 中没有 react-dom 的依赖?
卧槽卧槽。。。 我的锅。。。。sorry
Describe the bug
yarn run v1.22.19 warning package.json: No license field $ cross-env LOCAL=LOCAL ice start ⠸ loading config... ERROR Failed to get app config. 00:54:58
run DEBUG_TAG=app-config npm run dev to view error details 00:54:58 /node_modules/@ice/app/esm/createService.js:322 const appConfig = (await getAppConfig()).default; ^
TypeError: Cannot read properties of undefined (reading 'default') at createService (/node_modules/@ice/app/esm/createService.js:322:46) at Command. (/node_modules/@ice/app/bin/ice-cli.mjs:66:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Expected behavior
正常运行
Actual behavior
"@applint/spec": "^1.2.3", "@arco-design/web-react": "^2.52.0", "@ice/app": "^3.3.0", "@ice/plugin-auth": "^1.0.1", "@ice/plugin-icestark": "^1.0.5", "@ice/plugin-request": "^1.0.1", "@ice/plugin-store": "^1.1.1", "@ice/stark-app": "^1.5.0", "@ice/plugin-antd": "^1.0.1", "@ice/runtime": "^1.0.0",
Version of ice.js
3.0.0
Content of build.json or ice.config.mts
Additional context
No response