2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ライブラリインストール時nuxt prepareが失敗した時の対処

Last updated at Posted at 2024-01-10

困っていたこと

nuxt.config.tsに下記のようにライブラリのインポートが記述してあると、npm installnpm 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 installnpm ciにつけるだけ。
ただし、暫定っぽい対策な気はする。

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?