久し振りに npm build してみたら以下のエラーが・・・。
@types/node の中ということで厄介なパターンですね。
1 2 3 4 5 6 7 8 9 10 11 12 | node_modules/@types/node/globals.d.ts:72:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'AbortSignal' must be of type '{ new (): AbortSignal; prototype: AbortSignal; abort(reason?: any): AbortSignal; timeout(milliseconds: number): AbortSignal; }', but here has type '{ new (): AbortSignal; prototype: AbortSignal; }'. 72 declare var AbortSignal: { ~~~~~~~~~~~ node_modules/typescript/lib/lib.dom.d.ts:2071:13 2071 declare var AbortSignal: { ~~~~~~~~~~~ 'AbortSignal' was also declared here. Found 1 error. |
今回は、このエラーの対応をしていきます。
typescriptのアップデート
似たようなエラーが下記の Issue にありましたが、どこまで参考になるのか。
@types/node や typescript のアップデートをすれば解決しそうな気もしますね。
依存関係まで含めると npx コマンドが便利のようです。
npx npm-upgrade
では、npx npm-upgrade でアップデートを試してみましょう。
モジュールごとに確認が入るので邪魔ですが、-y か –yes のオプションで強制実行できるのかな。
1 2 3 4 | $ man npx To prevent security and user-experience problems from mistyping package names, npx prompts before installing anything. Suppress this prompt with the -y or --yes option. |
では実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | $ npx npm-upgrade Need to install the following packages: npm-upgrade Ok to proceed? (y) y npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs npm WARN deprecated libnpmconfig@1.2.1: This module is not used anymore. npm config is parsed by npm itself and by @npmcli/config npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 Checking for outdated production, optional, development, peer and bundled dependencies for "/hoge/package.json"... [====================] 12/12 100% New versions of active modules available: @types/node ^17.0.40 → ^18.11.11 @typescript-eslint/eslint-plugin ^5.28.0 → ^5.45.1 @typescript-eslint/parser ^5.28.0 → ^5.45.1 eslint ^8.17.0 → ^8.29.0 eslint-plugin-jsdoc ^39.3.2 → ^39.6.4 typescript ^4.7.2 → ^4.9.3 yargs ^17.5.1 → ^17.6.2 @types/yargs ^17.0.10 → ^17.0.16 ? Update "@types/node" in package.json from ^17.0.40 to ^18.11.11? Yes ? Update "@typescript-eslint/eslint-plugin" in package.json from ^5.28.0 to ^5.45.1? Yes ? Update "@typescript-eslint/parser" in package.json from ^5.28.0 to ^5.45.1? Yes ? Update "eslint" in package.json from ^8.17.0 to ^8.29.0? Yes ? Update "eslint-plugin-jsdoc" in package.json from ^39.3.2 to ^39.6.4? Yes ? Update "typescript" in package.json from ^4.7.2 to ^4.9.3? Yes ? Update "yargs" in package.json from ^17.5.1 to ^17.6.2? Yes ? Update "@types/yargs" in package.json from ^17.0.10 to ^17.0.16? Yes These packages will be updated: @types/node ^17.0.40 → ^18.11.11 @typescript-eslint/eslint-plugin ^5.28.0 → ^5.45.1 @typescript-eslint/parser ^5.28.0 → ^5.45.1 eslint ^8.17.0 → ^8.29.0 eslint-plugin-jsdoc ^39.3.2 → ^39.6.4 typescript ^4.7.2 → ^4.9.3 yargs ^17.5.1 → ^17.6.2 @types/yargs ^17.0.10 → ^17.0.16 ? Update package.json? Yes |
これで無事に npm build することができました。