LoginSignup
1
1

More than 3 years have passed since last update.

Nuxt.jsのバージョンを下げてみた(2.14.x → 2.13.x / 2.12.x)

Last updated at Posted at 2020-08-18

背景

create-nuxt-appは非常に便利だが、その時点での最新のNuxt.jsでプロジェクトが作成される。

Nuxt.jsでSPAを作成していたのだが、ある問題の調査のためにNuxt.jsのダウングレードを試してみた。
そのときの手順を参考までに残しておく。

基本的な流れ

  1. インストール済みの依存パッケージを全て削除
  2. package.jsonを修正
  3. 依存パッケージを再インストール
  4. nuxt.config.jsをバージョンに合わせて修正

手順

2.14.x → 2.13.x

1. インストール済みの依存パッケージを全て削除

# 既存の依存パッケージとビルド成果物を削除
rm -rf node_modules/ dist/

# yarnの場合
rm yarn.lock

# npmの場合
rm package-lock.json

2. package.jsonを修正

修正するのは下記の2点

  • scripts
    • generateを削除
    • exportserveを追加
  • dependencies
    • <2.14.0とすれば、2.14.0未満、つまり2.13.x系の最新バージョンがインストールされる。
package.json
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "export": "nuxt export",
    "serve": "nuxt serve"
  },
  "dependencies": {
    "nuxt": "<2.14.0"
  },

3. 依存パッケージを再インストール

# yarnの場合
yarn install

# npmの場合
npm install

4. nuxt.config.jsをバージョンに合わせて修正

2.14.x → 2.13.xの場合は修正は不要そう。
間違っていたらごめんなさい。

2.14.x → 2.12.x

1. インストール済みの依存パッケージを全て削除

# 既存の依存パッケージとビルド成果物を削除
rm -rf node_modules/ dist/

# yarnの場合
rm yarn.lock

# npmの場合
rm package-lock.json

2. package.jsonを修正

修正するのは下記の2点

  • scripts
    • startを削除
  • dependencies
    • <2.13.0とすれば、2.13.0未満、つまり2.12.x系の最新バージョンがインストールされる。
package.json
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "generate": "nuxt generate",
  },
  "dependencies": {
    "nuxt": "<2.13.0"
  },

3. 依存パッケージを再インストール

# yarnの場合
yarn install

# npmの場合
npm install

4. nuxt.config.jsをバージョンに合わせて修正

修正するのは下記の2点

  • target: 'static'をコメントアウト
  • components: trueをコメントアウト
nuxt.config.js
export default {
      :
    (省略)
      :
  /*
  ** Nuxt target
  ** See https://nuxtjs.org/api/configuration-target
  */
  // target: 'static'
      :
    (省略)
      :
  /*
  ** Auto import components
  ** See https://nuxtjs.org/api/configuration-components
  */
  // components: true
      :
    (省略)
      :
}
1
1
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
1
1