困っていたこと
nuxt.config.ts
に下記のようにライブラリのインポートが記述してあると、npm install
やnpm ci
でエラーになってしまう。
nuxt.config.ts
import axios from 'axios'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
エラーメッセージは以下。
$ npm ci
> postinstall
> nuxt prepare
Error: connect ECONNREFUSED ::1:80
at AxiosError.from (node_modules/axios/dist/node/axios.cjs:837:14)
at RedirectableRequest.handleRequestError (node_modules/axios/dist/node/axios.cjs:3090:25)
at RedirectableRequest.emit (node:events:517:28)
at eventHandlers.<computed> (node_modules/follow-redirects/index.js:37:24)
at ClientRequest.emit (node:events:517:28)
at Socket.socketErrorListener (node:_http_client:501:9)
at Socket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
解決策
原因はインストール完了後に走るnuxt prepare
のようなのでこれを抑制した。
方法は--ignore-scripts
オプションをnpm install
やnpm ci
につけるだけ。
ただし、暫定っぽい対策な気はする。
参考