2

我一直在按照本教程使用云应用程序编程模型(Node.js)开发应用程序: https ://github.com/SAP-samples/cloud-cap-nodejs-codejam

不幸的是,我无法将它部署到 Cloud Foundry。我还从上面的教程中创建了应用程序(书店),以检查我是否遇到了同样的错误,我确实遇到了。

错误如下所示,当我尝试执行npm run build:mta练习 10 中的命令时发生。

[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! bookshop@1.0.0 build:mta: `cds build/all && mbt build -p=cf`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bookshop@1.0.0 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 npm@6.14.8
3 info using node@v12.19.0
4 verbose run-script [ 'prebuild:mta', 'build:mta', 'postbuild:mta' ]
5 info lifecycle bookshop@1.0.0~prebuild:mta: bookshop@1.0.0
6 info lifecycle bookshop@1.0.0~build:mta: bookshop@1.0.0
7 verbose lifecycle bookshop@1.0.0~build:mta: unsafe-perm in lifecycle true
8 verbose lifecycle bookshop@1.0.0~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 bookshop@1.0.0~build:mta: CWD: C:\Users\XXXXX\Desktop\SAPProject\bookshop
10 silly lifecycle bookshop@1.0.0~build:mta: Args: [ '/d /s /c', 'cds build/all && mbt build -p=cf' ]
11 silly lifecycle bookshop@1.0.0~build:mta: Returned: code: 1  signal: null
12 info lifecycle bookshop@1.0.0~build:mta: Failed to exec build:mta script
13 verbose stack Error: bookshop@1.0.0 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 bookshop@1.0.0
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 bookshop@1.0.0 build:mta: `cds build/all && mbt build -p=cf`
22 error Exit status 1
23 error Failed at the bookshop@1.0.0 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}

有没有人也遇到过这个问题?任何帮助将不胜感激。

4

1 回答 1

0

您用于为项目构建 mta 的命令 - 在npm run build:mta内部使用SAP Cloud MTA Build Tool,简称为 MBT。MBT 在内部使用GNU Make如此处所指定。尝试按照此处的说明进行安装,然后再次尝试使用相同的命令为您的项目构建 mta - 。它将成功构建。GNU Makenpm run build:mta

于 2021-03-01T10:41:30.393 回答