问题描述
按照该教程,我一直在使用Cloud Application Programming Model(Node.js)开发应用程序: https://github.com/SAP-samples/cloud-cap-nodejs-codejam
很不幸,我无法将其部署到Cloud Foundry。我还根据上面的教程创建了应用(书店),以检查是否遇到相同的错误,并且确实如此。
该错误看起来如下,当我尝试从练习10执行npm run build:mta
命令时,就会发生该错误。
[2020-11-03 15:29:43] INFO executing the "make -f Makefile_20201103152943.mta p=cf mtar= strict=true mode=" command...
[2020-11-03 15:29:45] INFO validating the MTA project
[2020-11-03 15:29:45] ERROR the "mta.yaml" file is not valid:
line 28: the "srv-binding" property set required by the "bookshop-ui" module is not defined
line 34: the "url" property of the "bookshop-ui" module is unresolved; the "srv-binding/srv-url" property is not provided
make: *** [Makefile_20201103152943.mta:26: pre_validate] Error 1
Error: Could not build the MTA project: Could not execute the "make -f Makefile_20201103152943.mta p=cf mtar= strict=true mode=" command: exit status 2
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:mta: `cds build/all && mbt build -p=cf`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:mta script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
完整的调试日志:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',1 verbose cli 'C:\\Users\\XXXXX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',1 verbose cli 'run',1 verbose cli 'build:mta'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild:mta','build:mta','postbuild:mta' ]
5 info lifecycle [email protected]~prebuild:mta: [email protected]
6 info lifecycle [email protected]~build:mta: [email protected]
7 verbose lifecycle [email protected]~build:mta: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build:mta: PATH: C:\Users\XXXXX\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\XXXXX\Desktop\SAPProject\bookshop\node_modules\.bin;C:\Program Files\Java\jdk1.8.0_172\bin;C:\Program Files\Java\jre1.8.0_172\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\apache-maven-3.6.3\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\PuTTY\;C:\Program Files\OpenJDK12\Bin;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Python\python37\Scripts\;C:\Python\python37\;C:\Users\XXXXXX\AppData\Local\Microsoft\WindowsApps;C:\Users\XXXXXX\AppData\Roaming\Cloud Foundry;C:\Users\XXXXX\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\XXXXXX\AppData\Roaming\npm;C:\Users\XXXXXX\AppData\Local\Programs\Git\cmd;
9 verbose lifecycle [email protected]~build:mta: CWD: C:\Users\XXXXX\Desktop\SAPProject\bookshop
10 silly lifecycle [email protected]~build:mta: Args: [ '/d /s /c','cds build/all && mbt build -p=cf' ]
11 silly lifecycle [email protected]~build:mta: Returned: code: 1 signal: null
12 info lifecycle [email protected]~build:mta: Failed to exec build:mta script
13 verbose stack Error: [email protected] build:mta: `cds build/all && mbt build -p=cf`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\XXXXX\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:314:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\XXXXXX\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:314:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\XXXXX\Desktop\SAPProject\bookshop
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\XXXXX\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build:mta"
18 verbose node v12.19.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build:mta: `cds build/all && mbt build -p=cf`
22 error Exit status 1
23 error Failed at the [email protected] build:mta script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1,true ]
mta.yml文件-与本教程中的完全相同
## Generated mta.yaml based on template version 0.4.0
## appName = bookshop
## language=nodejs; multiTenant=false
## approuter=
_schema-version: '3.1'
ID: bookshop
version: 1.0.0
description: "A simple CAP project."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p @sap/cds-dk cds build --production
modules:
############## UI MODULE ##########################
- name: bookshop-ui
type: nodejs
path: app
parameters:
memory: 256M
disk-quota: 256M
requires:
- name: srv-binding
group: destinations
properties:
forwardAuthToken: true
strictSSL: true
name: srv-binding
url: ~{srv-url}
# --------------------- SERVER MODULE ------------------------
- name: bookshop-srv
# ------------------------------------------------------------
type: nodejs
path: gen/srv
requires:
# Resources extracted from CAP configuration
- name: bookshop-db
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
# -------------------- SIDECAR MODULE ------------------------
- name: bookshop-db-deployer
# ------------------------------------------------------------
type: hdb
path: gen/db
parameters:
buildpack: nodejs_buildpack
requires:
# 'hana' and 'xsuaa' resources extracted from CAP configuration
- name: bookshop-db
resources:
# services extracted from CAP configuration
# 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
# ------------------------------------------------------------
- name: bookshop-db
# ------------------------------------------------------------
type: com.sap.xs.hdi-container
parameters:
service: hanatrial # or 'hanatrial' on trial landscapes
service-plan: hdi-shared
properties:
hdi-service-name: ${service-name}
有人也遇到过这个问题吗?任何帮助将不胜感激。
解决方法
bookshop-srv是否应提供UI所需的内容?在我看来,bookshop-srv应该提供srv-binding(而不是srv-api),反之亦然。
,您用于为项目构建 mta 的命令 - npm run build:mta
在内部使用 SAP Cloud MTA Build Tool,简称为 MBT。 MBT 在内部使用 GNU Make
,如指定的 here。尝试按照说明 here 安装 GNU Make
,然后使用相同的命令 - npm run build:mta
再次尝试为您的项目构建 mta。它将成功构建。