LoginSignup
1
1

More than 3 years have passed since last update.

Now.shにNuxt.jsのアプリケーションをデプロイしようとしたときのバージョンエラーメモ

Posted at

npx create-nuxt-app <app名>で作成したNuxt.jsアプリケーションをNow.shにデプロイしようとした時の話です。

基本

公式のNow へデプロイするには?を見つつプロジェクトのルートにnow.jsonを作成するだけです。

now.json
{
  "version": 2,
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/now-builder",
      "config": {}
    }
  ]
}

あとはnowコマンドでデプロイされます。

$ now

Node.jsのバージョンでハマる

こんな感じでエラーが

> Deploying ~/dotstudio/playground/xxxxxxxx under n0bisuke
> Using project gahaku
> Synced 1 file (504B) [498ms]
> https://xxxxxxxx.now.sh [v2] [809ms]
> Error! Build failed
> Error! Check your logs at https://xxxxxxxxxxxxxx.now.sh/_logs or run `now logs xxxxxxxxxxxxxx.now.sh

ログをのぞいてみたら、Now.sh上のNode.jsのバージョンがデフォで8.10.x
なんだけど、依存モジュールが8.12.0以上欲しい、みたいなエラーが出てました。

missing `engines` in `package.json`, using default range: 8.10.x
Using yarn
ℹ Prepare build took: 188.356777 ms
 ----------------- Install devDependencies ----------------- 
Running yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --modules-folder=/tmp/c428239/node_modules --cache-folder=/tmp/c428239/.now_cache/yarn
yarn install v1.17.3
[1/5] Resolving packages...
[2/5] Fetching packages...
error execa@2.0.4: The engine "node" is incompatible with this module. Expected version "^8.12.0 || >=9.7.0". Got "8.10.0"
error Found incompatible module.

enginesはnow.jsonではなくpackage.jsonに

now.json内にenginesを記載したら怒られました。

$ now

・
・
・
> Error! The property `engines` is not allowed in now.json when using Now 2.0 – please remove it.

Now.shは現時点で8系か10系しか使えなかった

package.jsonにenginesを指定することはわかったので現時点最新の"engines": { "node": "12.10.0" }を指定したところ怒られました。

downloading cache...
 ----------------- Prepare build ----------------- 
Downloading files...
Working directory: /tmp/22f71c4b
Error: found `engines` in `package.json` with an unsupported node range: 12.10.0
please use `10.x` or `8.10.x` instead
    at Object.getSupportedNodeVersion (/tmp/5c75e02affa7ea9e/.build-utils/node_modules/@now/build-utils/dist/index.js:19096:23)
    at getNodeVersion (/tmp/5c75e02affa7ea9e/.build-utils/node_modules/@now/build-utils/dist/index.js:21035:27)
    at <anonymous>
worker exited with code 20 and signal null
done

10.x or 8.10.xって言われてますね

10.xx.xxの指定は出来ずに10.xだと通った

12系が使えないことが分かったので、"engines": { "node": "10.16.3" }を指定したところ怒られました。

 ----------------- Prepare build ----------------- 
Downloading files...
Working directory: /tmp/fee663a
Found `engines` in `package.json`, selecting range: 10.x
Using yarn
ℹ Prepare build took: 192.035346 ms
 ----------------- Install devDependencies ----------------- 
Running yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --modules-folder=/tmp/fee663a/node_modules --cache-folder=/tmp/fee663a/.now_cache/yarn
yarn install v1.17.3
[1/6] Validating package.json...
error gahaku@1.0.0: The engine "node" is incompatible with this module. Expected version "10.16.3". Got "10.16.0"

10.16は大丈夫だけど10.16.3はダメらしい。

結局

package.json"engines": { "node": "10.16" },を書くことで解消しました。

迷路の右手法のように試すたびにエラーが出てました苦笑

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