我正在尝试在 SAP Business Application Studio 中创建一个标准的 SAP CAP(云平台应用程序模型),并且除了 CDS 服务提供的端点之外,还使用其他 Express 端点对其进行扩展。我有以下项目结构:
package.json 的内容:
{
"name": "<app-name>",
"version": "1.0.0",
"description": "A simple CAP project.",
"repository": "<Add your repository here>",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@sap/cds": "^3",
"@sap/cds-dk": "^1.8.5",
"@sap/hana-client": "^2.4.177",
"express": "^4",
"multer": "^1.4.2"
},
"scripts": {
"start": "npx cds run"
},
"cds": {
"hana": {
"deploy-format": "hdbtable"
},
"requires": {
"db": {
"kind": "sql"
}
}
},
"devDependencies": {
"sqlite3": "^4.2.0"
}}
服务器.js:
module.exports = async() => {
const express = require('express')
const cds = require('@sap/cds')
const app = express()
const port = process.env.port || 4004
app.use('/', express.static('app/'))
app.get('/', (req, res) => res.redirect("/app/index.html"))
cds.connect("db")
.serve("all")
.in(app)
return app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))}
当我运行cds watch命令时,应用程序正确启动,但是当我打开 Fiori Elements 应用程序时,会出现以下错误消息:
如果我从 srv 文件夹中删除 server.js 文件,则该应用程序运行良好。什么可能导致错误消息?是否需要任何额外的配置?