SAP/ui5-tooling

Could not create Module: Missing or empty parameter 'version'

Closed this issue · 5 comments

Expected Behavior

  • Can run build successfully

Current Behavior

  • Can't build got issue Could not create Module: Missing or empty parameter 'version'

Steps to Reproduce the Issue

  1. Create a script inside package.json "build:cf": "ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateManifestBundle generateCachebusterInfo",
  2. run npm run build:cf
  3. got error Could not create Module: Missing or empty parameter 'version'
    alt Could not create Module: Missing or empty parameter 'version

Context

  • UI5 Module Version (output of ui5 --version when using the CLI): 3.4.1
  • Node.js Version: v18.14.2
  • npm Version: 9.5.0
  • OS/Platform: BAS
  • Browser (if relevant): Chrome
  • Other information regarding your environment (optional): nothing

Log Output / Stack Trace

ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateManifestBundle generateCachebusterInfo --verbose

verb cli:middlewares:base using @ui5/cli version 3.4.1 (from /home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/bin/ui5.cjs)
verb cli:middlewares:base using node version v18.14.2
verb generateProjectGraph Creating project graph using npm provider...
verb generateProjectGraph No workspace configuration file provided at /home/user/projects/cnma_adminconfiguration/app/ui5-workspace.yaml
NodePackageDependencies {
  _cwd: '/home/user/projects/cnma_adminconfiguration/app',
  _rootConfiguration: undefined,
  _rootConfigPath: '/home/user/projects/cnma_adminconfiguration/app/ui5-deploy.yaml'
}

⚠️  Process Failed With Error

Error Message:
Could not create Module: Missing or empty parameter 'version'

Stack Trace:
Error: Could not create Module: Missing or empty parameter 'version'
    at new Module (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/Module.js:49:10)
    at projectGraphBuilder (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/projectGraphBuilder.js:111:21)
    at async graphFromPackageDependencies (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/graph.js:73:23)
    at async Object.handleBuild [as handler] (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/lib/cli/commands/build.js:148:11)

Hi and thanks for reporting this!

Based on the error, I suspect that the package.json of your project does not contain a "version" field. Is that right?

We should definitely improve the error message, but we require a version in the package.json.

Hi @RandomByte
Thanks for your advice
Double-check and I see a missing version inside package.json. So, I think we should update the error message in that case to easy to understand something like Missing or empty parameter 'version' in the package.json. Cause, when I see the message Missing or empty parameter 'version' I just check inside ui5-deploy.yaml or ui5.yaml.
After adding the version, I faced another issue:

  • Failed to add extension sap-fe-mockserver to graph: An extension with that name has already been added

This is trace logs

Error Message:
Failed to add extension sap-fe-mockserver to graph: An extension with that name has already been added

Stack Trace:
Error: Failed to add extension sap-fe-mockserver to graph: An extension with that name has already been added
    at ProjectGraph.addExtension (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/ProjectGraph.js:127:10)
    at file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/projectGraphBuilder.js:17:10
    at Array.forEach (<anonymous>)
    at _handleExtensions (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/projectGraphBuilder.js:9:13)
    at handleExtensions (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/projectGraphBuilder.js:142:10)
    at projectGraphBuilder (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/projectGraphBuilder.js:227:6)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async graphFromPackageDependencies (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/node_modules/@ui5/project/lib/graph/graph.js:73:23)
    at async Object.handleBuild [as handler] (file:///home/user/projects/cnma_adminconfiguration/app/node_modules/@ui5/cli/lib/cli/commands/build.js:148:11)

Also this I my ui5-deploy.yaml

specVersion: '3.0'
metadata:
  name: cnma_adminconfiguration_ui
type: application
# ui5Version: 
# ui5Theme: sap_fiori_3
resources:
  configuration:
    propertiesFileSourceEncoding: UTF-8
builder:
  resources:
    excludes:
      - "node_modules/**"
  customTasks:
  - name: webide-extension-task-updateManifestJson
    beforeTask: generateManifestBundle
    configuration:
      appFolder: ./webapp
      destDir: ./dist
  - name: ui5-task-zipper
    afterTask: generateCachebusterInfo
    configuration:
      archiveName: uiapp_content
      additionalFiles:
      - xs-app.json

Do you have any idea or adive?

This error indicates that your project's dependency tree contains two npm packages (with different package names!) that both contain an extension with the name sap-fe-mockserver (as defined in the respective ui5.yaml).

This is probably caused by the deprecation of the @sap/ux-ui5-fe-mockserver-middleware package which got replaced by @sap-ux/ui5-middleware-fe-mockserver.

Check the output of npm ls to see whether your project or any of its dependencies depends on @sap/ux-ui5-fe-mockserver-middleware and try to remove that dependency.

hi @RandomByte
I've downgraded ui5 tooling to version 2 and fixed the package by package-lock.json and it's working well now. I may need to update and migrate to version 3 later. But for now, keep version 2 in my project for stable
Thanks so much for your support
Close this issue now

matz3 commented

@leotrinh please keep in mind that version 2 is not maintained anymore and more importantly, the consumption of framework libraries via ui5.yaml is not possible for OpenUI5/SAPUI5 version 1.116 and above. An upgrade to version 3 is mandatory to be able to consume 1.116 and above.

See @RandomByte's blog post for more details: https://blogs.sap.com/2023/05/24/upgrade-your-tools-for-modern-ecmascript-in-ui5/

Please let us know if there's still something hindering you from upgrading to v3. We're happy to support 👍🏻