SAP / ui5-tooling

An open and modular toolchain to develop state of the art applications based on the UI5 framework
https://sap.github.io/ui5-tooling
Apache License 2.0
469 stars 71 forks source link

Require() of ES Module is not supported. UI5 tooling failed to start with server middleware #856

Closed C3ntraX closed 1 year ago

C3ntraX commented 1 year ago

Expected Behavior

UI5-Tooling to start my app.

Current Behavior

I cann't start UI5-Tooling with any middleware or I get the following error:

โš ๏ธ Process Failed With Error

Error Message: require() of ES Module C:\Users*\node_modules\wrap-ansi\index.js from C:\Users*\node_modules\cliui\build\index.cjs not supported. Instead change the require of index.js in C:\Users***\node_modules\cliui\build\index.cjs to a dynamic import() which is available in all CommonJS modules.

Stack Trace: Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users*\node_modules\wrap-ansi\index.js from C:\Users*\node_modules\cliui\build\index.cjs not supported. Instead change the require of index.js in C:\Users*\node_modules\cliui\build\index.cjs to a dynamic import() which is available in all CommonJS modules. at Object. (C:\Users*\node_modules\cliui\build\index.cjs:293:14) at Object. (C:\Users*\node_modules\yargs\build\index.cjs:1:60678) at Object. (C:\Users*\node_modules\yargs\index.cjs:5:30) at module.exports (C:\Users***\node_modules\ui5-middleware-livereload\lib\livereload.js:106:14)

Steps to Reproduce the Issue

Use the following settings:

specVersion: "3.0"
metadata:
   name: erzeugniskalkulation
type: application
framework:
   name: OpenUI5
   version: "1.71.58"
   libraries:
      - name: sap.f
      - name: sap.m
      - name: sap.tnt
      - name: sap.ui.core
      - name: sap.ui.layout
      - name: themelib_sap_belize
server:
   settings:
      httpPort: 3000
   customMiddleware:
      - name: ui5-middleware-livereload
        afterMiddleware: compression
        configuration:
           debug: true
           extraExts: "xml,json,properties"
           port: 35730
           watchPath: "webapp"

Context

Packages:

"devDependencies": {
      "@ui5/cli": "3.3.1",
      "ui5-middleware-livereload": "^3.0.0",
      "ui5-middleware-simpleproxy": "^3.0.0",
      "ui5-task-i18ncheck": "^3.0.0",
      "ui5-tooling-stringreplace": "3.0.0",
      "ui5-tooling-transpile": "3.0.1"
   },
"scripts": {
      "start": "ui5 serve --accept-remote-connections",
   },

Log Output / Stack Trace

See above
C3ntraX commented 1 year ago

It seeems that my yarn.lock had wrong resoultions. Dont know why but after I deleted the yarn.lock and let yarn to autogernerate a new yarn.lock, it works.

RandomByte commented 1 year ago

Hi @C3ntraX, thanks for reporting.

I tried to reproduce this issue by setting up a local project with the provided ui5.yaml and the listed npm devDependencies. Unfortunately I'm unable to reproduce the issue.

I attached my test project here: ui5-tooling-issue-856.zip

Just execute npm install and npm start. The server should come up fine.

I can only suggest to delete the node_modules directory and the package-lock.json and yarn.lock files in your project. Then reinstall all dependencies (maybe try npm first to rule out an issue with Yarn) and try again.

The error message sounds like a coding issue in one of the dependencies.

RandomByte commented 1 year ago

It seeems that my yarn.lock had wrong resoultions. Dont know why but after I deleted the yarn.lock and let yarn to autogernerate a new yarn.lock, it works.

Alright, glad to hear that ๐Ÿ˜„๐Ÿ‘Œ

C3ntraX commented 1 year ago

Hi @RandomByte,

thanks for the fast response ๐Ÿ‘ I think I already resolved this issue