ioBroker / create-adapter

Command line utility to create customized ioBroker adapters
MIT License
50 stars 23 forks source link

Creating new TypeScript Adapter ends in [2/4] Installing dependencies... ERESOLVE could not resolve #1108

Closed jb-io closed 1 month ago

jb-io commented 2 months ago
$ docker run -it --rm -v.:/project node:20 bash

root@a3c9935640f9:/# cd /project/

root@a3c9935640f9:/project# node -v
v20.17.0
root@a3c9935640f9:/project# npm -v
10.8.2

Trying to run create-adapter with all values as default except selecting TypeScript instead of JavaScript

root@a3c9935640f9:/project# npx @iobroker/create-adapter@latest
Need to install the following packages:
@iobroker/create-adapter@2.6.3
Ok to proceed? (y) 

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@8.1.0: Glob versions prior to v9 are no longer supported
npm warn deprecated google-p12-pem@4.0.1: Package is no longer maintained
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported

=====================================================
   Welcome to the ioBroker adapter creator v2.6.3!
=====================================================

You can cancel at any point by pressing Ctrl+C.

Let's get started with a few questions about your project!
✔ Please enter the name of your project: · test
✔ Which title should be shown in the admin UI? · test
✔ Please enter a short description: · test
✔ Enter some keywords (separated by commas) to describe your project: · 
✔ If you have any contributors, please enter their names (seperated by commas): · 

Nice! Let's get technical...
✔ How detailed do you want to configure your project? · no
✔ Which features should your project contain? · adapter
✔ Which category does your adapter fall into? · alarm
✔ From where will the adapter get its data? · cloud
✔ How will the adapter receive its data? · poll

Some more questions about the source code...
✔ Which language do you want to use to code the adapter? · TypeScript
✔ Which framework would you like to use for the Admin UI? · json
✔ Which of the following tools do you want to use? · ESLint
✔ Would you like to automate new releases with one simple command? · yes
✔ Would you like to use dev-server to develop and test your code with a simple command line tool? · yes
✔ Please choose the port number on which dev-server should present the admin web interface: · 8081
✔ Do you prefer tab or space indentation? · Tab
✔ Do you prefer double or single quotes? · double

Almost done! Just a few administrative details...
✔ Please enter your name (or nickname): · test
✔ What's your name/org on GitHub? · test
✔ What's your email address? · test@test.test
✔ Which license should be used for your project? · MIT License

That's it. Please wait a minute while I get this working...
[1/4] Generating files...
Using Legacy Google Translate
[2/4] Installing dependencies...
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: sinon-chai@4.0.0
npm error Found: chai@4.5.0
npm error node_modules/chai
npm error   dev chai@"^4.5.0" from the root project
npm error   chai@"^4.3.7" from @iobroker/testing@4.1.3
npm error   node_modules/@iobroker/testing
npm error     dev @iobroker/testing@"^4.1.3" from the root project
npm error   3 more (chai-as-promised, sinon-chai, chai-as-promised)
npm error
npm error Could not resolve dependency:
npm error peer chai@"^5.0.0" from sinon-chai@4.0.0
npm error node_modules/sinon-chai
npm error   dev sinon-chai@"^4.0.0" from the root project
npm error
npm error Conflicting peer dependency: chai@5.1.1
npm error node_modules/chai
npm error   peer chai@"^5.0.0" from sinon-chai@4.0.0
npm error   node_modules/sinon-chai
npm error     dev sinon-chai@"^4.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /root/.npm/_logs/2024-09-05T15_48_55_331Z-eresolve-report.txt
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-09-05T15_48_55_331Z-debug-0.log
[3/4] Compiling source files...

  build/main.js      4.4kb
  build/main.js.map  7.4kb

⚡ Done in 4ms
❌ Type-checking ./tsconfig.build.json failed!
[4/4] Installing dev-server...

added 430 packages in 10s
Using default profile default
Using profile name "default"
Using adapter name "test"
Build iobroker.test
/project/ioBroker.test> npm run build

> iobroker.test@0.0.1 prebuild
> rimraf build

> iobroker.test@0.0.1 build
> build-adapter ts

Compiling TypeScript with ESBuild...

  build/main.js      4.4kb
  build/main.js.map  7.4kb

⚡ Done in 3ms

Type-checking ./tsconfig.build.json with tsc...
src/main.ts:19:8 - error TS2339: Property 'on' does not exist on type 'Test'.
19   this.on("ready", this.onReady.bind(this));
          ~~
src/main.ts:20:8 - error TS2339: Property 'on' does not exist on type 'Test'.
20   this.on("stateChange", this.onStateChange.bind(this));
          ~~
src/main.ts:23:8 - error TS2339: Property 'on' does not exist on type 'Test'.
23   this.on("unload", this.onUnload.bind(this));
          ~~
src/main.ts:34:8 - error TS2339: Property 'log' does not exist on type 'Test'.
34   this.log.info("config option1: " + this.config.option1);
          ~~~
src/main.ts:34:43 - error TS2339: Property 'config' does not exist on type 'Test'.
34   this.log.info("config option1: " + this.config.option1);
                                             ~~~~~~
src/main.ts:35:8 - error TS2339: Property 'log' does not exist on type 'Test'.
35   this.log.info("config option2: " + this.config.option2);
          ~~~
src/main.ts:35:43 - error TS2339: Property 'config' does not exist on type 'Test'.
35   this.log.info("config option2: " + this.config.option2);
                                             ~~~~~~
src/main.ts:42:14 - error TS2339: Property 'setObjectNotExistsAsync' does not exist on type 'Test'.
42   await this.setObjectNotExistsAsync("testVariable", {
                ~~~~~~~~~~~~~~~~~~~~~~~
src/main.ts:55:8 - error TS2339: Property 'subscribeStates' does not exist on type 'Test'.
55   this.subscribeStates("testVariable");
          ~~~~~~~~~~~~~~~
src/main.ts:66:14 - error TS2339: Property 'setStateAsync' does not exist on type 'Test'.
66   await this.setStateAsync("testVariable", true);
                ~~~~~~~~~~~~~
src/main.ts:70:14 - error TS2339: Property 'setStateAsync' does not exist on type 'Test'.
70   await this.setStateAsync("testVariable", { val: true, ack: true });
                ~~~~~~~~~~~~~
src/main.ts:73:14 - error TS2339: Property 'setStateAsync' does not exist on type 'Test'.
73   await this.setStateAsync("testVariable", { val: true, ack: true, expire: 30 });
                ~~~~~~~~~~~~~
src/main.ts:76:27 - error TS2339: Property 'checkPasswordAsync' does not exist on type 'Test'.
76   let result = await this.checkPasswordAsync("admin", "iobroker");
                             ~~~~~~~~~~~~~~~~~~
src/main.ts:77:8 - error TS2339: Property 'log' does not exist on type 'Test'.
77   this.log.info("check user admin pw iobroker: " + result);
          ~~~
src/main.ts:79:23 - error TS2339: Property 'checkGroupAsync' does not exist on type 'Test'.
79   result = await this.checkGroupAsync("admin", "admin");
                         ~~~~~~~~~~~~~~~
src/main.ts:80:8 - error TS2339: Property 'log' does not exist on type 'Test'.
80   this.log.info("check group user admin group admin: " + result);
          ~~~
src/main.ts:118:52 - error TS2694: Namespace 'global.ioBroker' has no exported member 'State'.
118  private onStateChange(id: string, state: ioBroker.State | null | undefined): void {
                                                       ~~~~~
src/main.ts:121:9 - error TS2339: Property 'log' does not exist on type 'Test'.
121    this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`);
            ~~~
src/main.ts:124:9 - error TS2339: Property 'log' does not exist on type 'Test'.
124    this.log.info(`state ${id} deleted`);
            ~~~

Found 19 errors in the same file, starting at: src/main.ts:19

❌ Type-checking ./tsconfig.build.json failed!
iobroker-dev-server setup [profile]

Set up dev-server in the current directory. This should always be called in the directory where the
io-package.json file of your adapter is located.

Options:
      --version       Show version number                                                  [boolean]
  -t, --temp          Temporary directory where the dev-server data will be located
                                                                   [string] [default: ".dev-server"]
      --help          Show help                                                            [boolean]
  -p, --adminPort     TCP port on which ioBroker.admin will be available    [number] [default: 8081]
  -j, --jsController  Define which version of js-controller to be used  [string] [default: "latest"]
  -a, --admin         Define which version of admin to be used          [string] [default: "latest"]
  -b, --backupFile    Provide an ioBroker backup file to restore in this dev-server         [string]
  -l, --symlinks      Use symlinks instead of packing and installing the current adapter for a
                      smoother dev experience. Requires JS-Controller 5+. [boolean] [default: false]

Error: Command failed: npm run build
    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at checkExecSyncError (node:child_process:891:11)
    at Object.execSync (node:child_process:963:15)
    at DevServer.execSync (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:1388:19)
    at DevServer.buildLocalAdapter (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:1305:18)
    at async DevServer.setupDevServer (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:1049:9)
    at async DevServer.setup (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:306:9)
    at async Object.handler (/usr/local/lib/node_modules/@iobroker/dev-server/dist/index.js:104:28) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 157,
  stdout: null,
  stderr: null
}

All done! Have fun programming! ♥
Just open /project/ioBroker.test in your favorite editor.

Hint: try CTRL-clicking the path if you have the editor open already.
npm notice
npm notice New patch version of npm available! 10.8.2 -> 10.8.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.3
npm notice To update run: npm install -g npm@10.8.3
npm notice

Trying to fix the issue:

root@a3c9935640f9:/project/ioBroker.test# npm i
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: sinon-chai@4.0.0
npm error Found: chai@4.5.0
npm error node_modules/chai
npm error   dev chai@"^4.5.0" from the root project
npm error   chai@"^4.3.7" from @iobroker/testing@4.1.3
npm error   node_modules/@iobroker/testing
npm error     dev @iobroker/testing@"^4.1.3" from the root project
npm error   3 more (chai-as-promised, sinon-chai, chai-as-promised)
npm error
npm error Could not resolve dependency:
npm error peer chai@"^5.0.0" from sinon-chai@4.0.0
npm error node_modules/sinon-chai
npm error   dev sinon-chai@"^4.0.0" from the root project
npm error
npm error Conflicting peer dependency: chai@5.1.1
npm error node_modules/chai
npm error   peer chai@"^5.0.0" from sinon-chai@4.0.0
npm error   node_modules/sinon-chai
npm error     dev sinon-chai@"^4.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /root/.npm/_logs/2024-09-05T15_49_53_988Z-eresolve-report.txt
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-09-05T15_49_53_988Z-debug-0.log

Next Try:

root@a3c9935640f9:/project/ioBroker.test# npm i --legacy-peer-deps

up to date, audited 426 packages in 1s

82 packages are looking for funding
  run `npm fund` for details

4 critical severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
root@a3c9935640f9:/project/ioBroker.test# npm run build

> iobroker.test@0.0.1 prebuild
> rimraf build

> iobroker.test@0.0.1 build
> build-adapter ts

Compiling TypeScript with ESBuild...

  build/main.js      4.4kb
  build/main.js.map  7.4kb

⚡ Done in 3ms

Type-checking ./tsconfig.build.json with tsc...
src/main.ts:19:8 - error TS2339: Property 'on' does not exist on type 'Test'.
19   this.on("ready", this.onReady.bind(this));
          ~~
src/main.ts:20:8 - error TS2339: Property 'on' does not exist on type 'Test'.
20   this.on("stateChange", this.onStateChange.bind(this));
          ~~
src/main.ts:23:8 - error TS2339: Property 'on' does not exist on type 'Test'.
23   this.on("unload", this.onUnload.bind(this));
          ~~
src/main.ts:34:8 - error TS2339: Property 'log' does not exist on type 'Test'.
34   this.log.info("config option1: " + this.config.option1);
          ~~~
src/main.ts:34:43 - error TS2339: Property 'config' does not exist on type 'Test'.
34   this.log.info("config option1: " + this.config.option1);
                                             ~~~~~~
src/main.ts:35:8 - error TS2339: Property 'log' does not exist on type 'Test'.
35   this.log.info("config option2: " + this.config.option2);
          ~~~
src/main.ts:35:43 - error TS2339: Property 'config' does not exist on type 'Test'.
35   this.log.info("config option2: " + this.config.option2);
                                             ~~~~~~
src/main.ts:42:14 - error TS2339: Property 'setObjectNotExistsAsync' does not exist on type 'Test'.
42   await this.setObjectNotExistsAsync("testVariable", {
                ~~~~~~~~~~~~~~~~~~~~~~~
src/main.ts:55:8 - error TS2339: Property 'subscribeStates' does not exist on type 'Test'.
55   this.subscribeStates("testVariable");
          ~~~~~~~~~~~~~~~
src/main.ts:66:14 - error TS2339: Property 'setStateAsync' does not exist on type 'Test'.
66   await this.setStateAsync("testVariable", true);
                ~~~~~~~~~~~~~
src/main.ts:70:14 - error TS2339: Property 'setStateAsync' does not exist on type 'Test'.
70   await this.setStateAsync("testVariable", { val: true, ack: true });
                ~~~~~~~~~~~~~
src/main.ts:73:14 - error TS2339: Property 'setStateAsync' does not exist on type 'Test'.
73   await this.setStateAsync("testVariable", { val: true, ack: true, expire: 30 });
                ~~~~~~~~~~~~~
src/main.ts:76:27 - error TS2339: Property 'checkPasswordAsync' does not exist on type 'Test'.
76   let result = await this.checkPasswordAsync("admin", "iobroker");
                             ~~~~~~~~~~~~~~~~~~
src/main.ts:77:8 - error TS2339: Property 'log' does not exist on type 'Test'.
77   this.log.info("check user admin pw iobroker: " + result);
          ~~~
src/main.ts:79:23 - error TS2339: Property 'checkGroupAsync' does not exist on type 'Test'.
79   result = await this.checkGroupAsync("admin", "admin");
                         ~~~~~~~~~~~~~~~
src/main.ts:80:8 - error TS2339: Property 'log' does not exist on type 'Test'.
80   this.log.info("check group user admin group admin: " + result);
          ~~~
src/main.ts:118:52 - error TS2694: Namespace 'global.ioBroker' has no exported member 'State'.
118  private onStateChange(id: string, state: ioBroker.State | null | undefined): void {
                                                       ~~~~~
src/main.ts:121:9 - error TS2339: Property 'log' does not exist on type 'Test'.
121    this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`);
            ~~~
src/main.ts:124:9 - error TS2339: Property 'log' does not exist on type 'Test'.
124    this.log.info(`state ${id} deleted`);
            ~~~

Found 19 errors in the same file, starting at: src/main.ts:19

❌ Type-checking ./tsconfig.build.json failed!

Further Log files:

/root/.npm/_logs/2024-09-05T15_48_55_331Z-eresolve-report.txt ``` # cat /root/.npm/_logs/2024-09-05T15_48_55_331Z-eresolve-report.txt 'Log files: /root/.npm/_logs/2024-09-05T15_48_55_331Z-debug-0.log # npm resolution error report While resolving: sinon-chai@4.0.0 Found: chai@4.5.0 node_modules/chai dev chai@"^4.5.0" from the root project chai@"^4.3.7" from @iobroker/testing@4.1.3 node_modules/@iobroker/testing dev @iobroker/testing@"^4.1.3" from the root project peer chai@">= 2.1.2 < 6" from chai-as-promised@7.1.2 node_modules/@iobroker/testing/node_modules/chai-as-promised chai-as-promised@"^7.1.1" from @iobroker/testing@4.1.3 node_modules/@iobroker/testing dev @iobroker/testing@"^4.1.3" from the root project peer chai@"^4.0.0" from sinon-chai@3.7.0 node_modules/@iobroker/testing/node_modules/sinon-chai sinon-chai@"^3.7.0" from @iobroker/testing@4.1.3 node_modules/@iobroker/testing dev @iobroker/testing@"^4.1.3" from the root project peer chai@">= 2.1.2 < 6" from chai-as-promised@8.0.0 node_modules/chai-as-promised dev chai-as-promised@"^8.0.0" from the root project Could not resolve dependency: peer chai@"^5.0.0" from sinon-chai@4.0.0 node_modules/sinon-chai dev sinon-chai@"^4.0.0" from the root project Conflicting peer dependency: chai@5.1.1 node_modules/chai peer chai@"^5.0.0" from sinon-chai@4.0.0 node_modules/sinon-chai dev sinon-chai@"^4.0.0" from the root project Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution. ```
/root/.npm/_logs/2024-09-05T15_49_53_988Z-debug-0.log ``` # cat /root/.npm/_logs/2024-09-05T15_49_53_988Z-debug-0.log 0 verbose cli /usr/local/bin/node /usr/local/bin/npm 1 info using npm@10.8.2 2 info using node@v20.17.0 3 silly config load:file:/usr/local/lib/node_modules/npm/npmrc 4 silly config load:file:/project/ioBroker.test/.npmrc 5 silly config load:file:/root/.npmrc 6 silly config load:file:/usr/local/etc/npmrc 7 verbose title npm i 8 verbose argv "i" 9 verbose logfile logs-max:10 dir:/root/.npm/_logs/2024-09-05T15_49_53_988Z- 10 verbose logfile /root/.npm/_logs/2024-09-05T15_49_53_988Z-debug-0.log 11 silly packumentCache heap:2197815296 maxSize:549453824 maxEntrySize:274726912 12 silly logfile done cleaning log files 13 silly idealTree buildDeps 14 silly fetch manifest @iobroker/types@^6.0.0 15 silly packumentCache full:https://registry.npmjs.org/@iobroker%2ftypes cache-miss 16 http fetch GET 200 https://registry.npmjs.org/@iobroker%2ftypes 96ms (cache hit) 17 silly packumentCache full:https://registry.npmjs.org/@iobroker%2ftypes set size:416114 disposed:false 18 silly placeDep ROOT @iobroker/types@6.0.11 OK for: @iobroker/adapter-core@3.1.6 want: ^6.0.0 19 silly fetch manifest chai@^5.0.0 20 silly packumentCache full:https://registry.npmjs.org/chai cache-miss 21 http fetch GET 200 https://registry.npmjs.org/chai 4ms (cache hit) 22 silly packumentCache full:https://registry.npmjs.org/chai set size:194264 disposed:false 23 verbose stack Error: could not resolve 23 verbose stack at PlaceDep.failPeerConflict (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:503:25) 23 verbose stack at new PlaceDep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:157:21) 23 verbose stack at #buildDepStep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:917:18) 23 verbose stack at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:181:7) 23 verbose stack at async Promise.all (index 1) 23 verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5) 23 verbose stack at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5) 23 verbose stack at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9) 23 verbose stack at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:74:5) 24 error code ERESOLVE 25 error ERESOLVE could not resolve 26 error 27 error While resolving: sinon-chai@4.0.0 27 error Found: chai@4.5.0 27 error node_modules/chai 27 error dev chai@"^4.5.0" from the root project 27 error chai@"^4.3.7" from @iobroker/testing@4.1.3 27 error node_modules/@iobroker/testing 27 error dev @iobroker/testing@"^4.1.3" from the root project 27 error 3 more (chai-as-promised, sinon-chai, chai-as-promised) 27 error 27 error Could not resolve dependency: 27 error peer chai@"^5.0.0" from sinon-chai@4.0.0 27 error node_modules/sinon-chai 27 error dev sinon-chai@"^4.0.0" from the root project 27 error 27 error Conflicting peer dependency: chai@5.1.1 27 error node_modules/chai 27 error peer chai@"^5.0.0" from sinon-chai@4.0.0 27 error node_modules/sinon-chai 27 error dev sinon-chai@"^4.0.0" from the root project 27 error 27 error Fix the upstream dependency conflict, or retry 27 error this command with --force or --legacy-peer-deps 27 error to accept an incorrect (and potentially broken) dependency resolution. 28 error 28 error 28 error For a full report see: 28 error /root/.npm/_logs/2024-09-05T15_49_53_988Z-eresolve-report.txt 29 silly unfinished npm timer reify 1725551394199 30 silly unfinished npm timer reify:loadTrees 1725551394201 31 silly unfinished npm timer idealTree:buildDeps 1725551394335 32 silly unfinished npm timer idealTree:node_modules/sinon-chai 1725551394442 33 verbose cwd /project/ioBroker.test 34 verbose os Linux 6.8.0-40-generic 35 verbose node v20.17.0 36 verbose npm v10.8.2 37 verbose exit 1 38 verbose code 1 39 error A complete log of this run can be found in: /root/.npm/_logs/2024-09-05T15_49_53_988Z-debug-0.log ```

This Problem seems to be independant on node version because it also fails on node 18 and node 22

Am i doing something wrong?

AlCalzone commented 2 months ago

I think we have to pin Chai to a lower version. There was another issue about this recently.