VSCode中Yeoman生成OData源SAP Fiori App时出现版本读取错误
问题描述
在MacOS系统下,使用VSCode通过Yeoman生成以OData为数据源的SAP Fiori应用时,抛出以下错误:
{"message":"@sap/fiori:app generator failed - env.on(error) Cannot read properties of undefined (reading 'version')","stack":"TypeError: env.on(error) Cannot read properties of undefined (reading 'version')\n\tat default_1._applyDefaults (/opt/homebrew/lib/node_modules/@sap/generator-fiori/generators/app-gen-shared/app/index.js:1:676600)\n\tat default_1.writing (/opt/homebrew/lib/node_modules/@sap/generator-fiori/generators/app-gen-shared/app/index.js:1:673522)\n\tat Object.<anonymous> (/opt/homebrew/lib/node_modules/@sap/generator-fiori/generators/commonlibs/index.js:2:4454280)\n\tat /opt/homebrew/lib/node_modules/@sap/generator-fiori/generators/commonlibs/index.js:2:3726211\n\tat new Promise (<anonymous>)\n\tat /opt/homebrew/lib/node_modules/@sap/generator-fiori/generators/commonlibs/index.js:2:3725971\n\tat g.add.once (/opt/homebrew/lib/node_modules/@sap/generator-fiori/generators/commonlibs/index.js:2:4454298)\n\tat Immediate.<anonymous> (/Users/mert/.vscode/extensions/sapos.yeoman-ui-1.13.0/dist/extension.js:2:1970918)\n\tat process.processImmediate (node:internal/timers:466:21)"}
已尝试证书、代理相关修复方案,均无效。另外,Firefox访问该OData URL可正常获取XML数据,但Safari访问时会弹出请求打开Outlook的弹窗,无法理解此现象。
可能的解决方案
修复Yeoman生成器的版本读取错误
- 检查全局安装的
@sap/generator-fiori版本:
若版本存在兼容性问题,卸载后重新安装最新稳定版:npm list -g @sap/generator-fiorinpm uninstall -g @sap/generator-fiori npm install -g @sap/generator-fiori@latest - 清理Yeoman缓存,避免缓存数据导致异常:
yo clean - 更新VSCode的Yeoman UI插件至最新版本,重启VSCode后重试生成操作。
解决Safari弹出Outlook的异常
- 原因分析:大概率是OData服务返回的响应头包含
Content-Disposition字段,且设置了类似attachment的参数,Safari将XML文件关联到了Outlook,触发打开请求。 - 验证步骤:
- 在Safari偏好设置的“高级”选项中,勾选“在菜单栏中显示开发菜单”
- 打开开发工具的“网络”面板,访问OData URL,查看响应头是否存在
Content-Disposition字段
- 修复方案:
- 联系后端服务团队调整响应头,移除或修改
Content-Disposition的设置 - 临时调整Safari关联设置:
- 打开“系统设置-隐私与安全性-文件和文件夹”,找到Outlook并取消其对XML文件类型的访问权限
- 右键任意XML文件,选择“显示简介”,在“打开方式”中选择Safari或其他文本编辑器,点击“全部更改”
- 联系后端服务团队调整响应头,移除或修改
内容的提问来源于stack exchange,提问作者jesuismert
相关产品推荐
相关产品推荐

