mbt: not found
Closed this issue · 2 comments
Hi!
In my projects I use workspaces.
So i have few nodejs apps. The problem starts at build:
cap-xsa: > cap-xsa@1.0.0 mbt
cap-xsa: > mbt build --platform xsa --mtar=${npm_package_name}.mtar
cap-xsa: [2024-09-27 17:09:35] INFO Cloud MTA Build Tool version 1.2.31
cap-xsa: [2024-09-27 17:09:35] INFO generating the "Makefile_20240927170935.mta" file...
cap-xsa: [2024-09-27 17:09:35] INFO done
cap-xsa: [2024-09-27 17:09:35] INFO executing the "make -f Makefile_20240927170935.mta p=xsa mtar=cap-xsa.mtar strict=true mode=" command...
cap-xsa: [2024-09-27 17:09:35] INFO validating the MTA project
cap-xsa: [2024-09-27 17:09:35] INFO running the "before-all" build...
cap-xsa: [2024-09-27 17:09:35] INFO executing the "npm run build" command...
cap-xsa: > cap-xsa@1.0.0 build
cap-xsa: > cds build
cap-xsa: Detected /mnt/wsl/workspace/ubuntu/cap-xsa/tsconfig.json. If this is a TypeScript project, consider running commands using cds-ts instead of cds.
cap-xsa: building project [/mnt/wsl/workspace/ubuntu/cap-xsa], clean [true]
cap-xsa: cds-dk [8.2.3], cds [8.2.3], compiler [5.2.0], home [/mnt/wsl/workspace/ubuntu/cap-xsa/node_modules/@sap/cds]
cap-xsa: {
cap-xsa: build: {
cap-xsa: target: 'gen',
cap-xsa: tasks: [
cap-xsa: { for: 'nodejs', src: 'srv', options: { model: ['db', 'srv', 'app'] }}
cap-xsa: ]
cap-xsa: }
cap-xsa: }
cap-xsa: done > wrote output to:
cap-xsa: gen/srv/package-lock.json
cap-xsa: gen/srv/package.json
cap-xsa: gen/srv/srv/csn.json
cap-xsa: gen/srv/srv/odata/v4/CatalogService.xml
cap-xsa: build completed in 296 ms
cap-xsa: [2024-09-27 17:09:35] INFO validating the MTA project
cap-xsa: [2024-09-27 17:09:35] INFO building the "cap-xsa-srv" module...
cap-xsa: [2024-09-27 17:09:35] INFO executing the "npm install --production" command...
cap-xsa: npm warn config production Use `--omit=dev` instead.
cap-xsa: .
cap-xsa: added 13 packages, and audited 15 packages in 1s
cap-xsa: 1 package is looking for funding
cap-xsa: run `npm fund` for details
cap-xsa: found 0 vulnerabilities
cap-xsa: [2024-09-27 17:09:36] INFO the build results of the "cap-xsa-srv" module will be packaged and saved in the "/mnt/wsl/workspace/ubuntu/cap-xsa/.cap-xsa_mta_build_tmp/cap-xsa-srv" folder
cap-xsa: [2024-09-27 17:09:36] INFO finished building the "cap-xsa-srv" module
cap-xsa: [2024-09-27 17:09:36] INFO building the "cap-xsa" module...
cap-xsa: [2024-09-27 17:09:36] INFO executing the "npm install --production" command...
cap-xsa: npm warn config production Use `--omit=dev` instead.
cap-xsa: .
cap-xsa: up to date, audited 626 packages in 1s
cap-xsa: 67 packages are looking for funding
cap-xsa: run `npm fund` for details
cap-xsa: found 0 vulnerabilities
cap-xsa: [2024-09-27 17:09:38] INFO the build results of the "cap-xsa" module will be packaged and saved in the "/mnt/wsl/workspace/ubuntu/cap-xsa/.cap-xsa_mta_build_tmp/cap-xsa" folder
cap-xsa: [2024-09-27 17:09:38] INFO finished building the "cap-xsa" module
cap-xsa: /bin/sh: 1: /mnt/wsl/workspace/ubuntu/cap-xsa/node_modules/mbt/unpacked_bin/mbt: not found
cap-xsa: Error: could not build the MTA project: could not execute the "make -f Makefile_20240927170935.mta p=xsa mtar=cap-xsa.mtar strict=true mode=" command: exit status 2
cap-xsa: [2024-09-27 17:09:38] ERROR could not build the MTA project: could not execute the "make -f Makefile_20240927170935.mta p=xsa mtar=cap-xsa.mtar strict=true mode=" command: exit status 2
So what just happens - is mbt being called - calls npm install --production for the module, but that module is a workspace - and it delets all non-production packages from node_modules and because of this mbt is not available anymore because is dev dependency.
So what I need is to force somehow mbt not to install dependencies anywhere. How to do this?
Thanks!
I suggest you should remove the mbt from your devdependencies in package.json and install mbt global with command line "npm install -g mbt" .
No actually I don't want to do this because this is how we build apps - we keep builder components in a dev dependencies so no surprises in CICD on version upgrades. But actually I found the reason- this not directly related to mbt but mainly to a builder config where before script is npm ci --production. The problem is - in combination with workspaces - it basically runs this command in a root folder and it removes all dev dependencies including mbt.
So the solution is to call npm ci but for the whole project ( or not call it at all ), that's it