Nuxt.js deploy fails, "FetchError: invalid json response body"

Hi,

I’m currently having an issue with Continuous Deployment, and have looked into a number of possible reasons online but none have helped me. This is a nuxt.js site being statically generated with their built in generate command.

The main issue is when I deploy it I get an error message when going to the page that says “Page Not Found Looks like you’ve followed a broken link or entered a URL that doesn’t exist on this site.” I understand is the cause of this issue is that there’s no index.html file. To confirm this I downloaded the generated build and see a 200.html but no index.html.

However when I run the same build command as I have configured in netlify (npm run generate), it does create the index.html file, but it doesn’t when I do it through netlify. If I drag and drop the dist folder that I create locally into netlify, then everything shows up on the site correctly.

My deployment settings in netlify are what I followed from the nuxt.js docs:
Repository : [my git repo]
Base Directory : Not set (also tried ‘/’ here but no change)
Build Command : npm run generate
Publish directory: dist

My output log from the deployment can be seen here:

9:35:29 AM: Build ready to start
9:35:35 AM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
9:35:35 AM: build-image tag: v3.3.5
9:35:35 AM: buildbot version: 2d05064ce3dd2eb95d282a24602ab707dd9581e8
9:35:35 AM: Fetching cached dependencies
9:35:35 AM: Starting to download cache of 132.3MB
9:35:36 AM: Finished downloading cache in 1.10126919s
9:35:36 AM: Starting to extract cache
9:35:42 AM: Finished extracting cache in 6.46150185s
9:35:43 AM: Finished fetching cache in 7.669479415s
9:35:43 AM: Starting to prepare the repo for build
9:35:43 AM: Preparing Git Reference refs/heads/master
9:35:44 AM: Starting build script
9:35:44 AM: Installing dependencies
9:35:45 AM: Started restoring cached node version
9:35:48 AM: Finished restoring cached node version
9:35:48 AM: v10.18.1 is already installed.
9:35:51 AM: Now using node v10.18.1 (npm v6.13.4)
9:35:52 AM: Attempting ruby version 2.6.2, read from environment
9:35:53 AM: Using ruby version 2.6.2
9:35:54 AM: Using PHP version 5.6
9:35:54 AM: Started restoring cached node modules
9:35:54 AM: Finished restoring cached node modules
9:35:54 AM: Started restoring cached go cache
9:35:54 AM: Finished restoring cached go cache
9:35:54 AM: unset GOOS;
9:35:54 AM: unset GOARCH;
9:35:54 AM: export GOROOT=’/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
9:35:54 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
9:35:54 AM: go version >&2;
9:35:54 AM: export GIMME_ENV=’/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
9:35:54 AM: go version go1.12 linux/amd64
9:35:54 AM: Installing missing commands
9:35:54 AM: Verify run directory
9:35:54 AM: Executing user command: npm run generate
9:35:54 AM: > microsite-snobrum-usa@1.0.0 generate /opt/build/repo
9:35:54 AM: > nuxt generate
9:35:55 AM: WARN No .env file found in /opt/build/repo.
9:35:56 AM: :information_source: Production build
9:35:56 AM: :heavy_check_mark: Builder initialized
9:35:57 AM: :heavy_check_mark: Nuxt files generated
9:35:58 AM: :information_source: Compiling Client
9:36:28 AM: :heavy_check_mark: Client: Compiled successfully in 29.96s
9:36:28 AM: :information_source: Compiling Server
9:36:33 AM: :heavy_check_mark: Server: Compiled successfully in 5.52s
9:36:33 AM: Hash: 7f266d6164c634694888
9:36:33 AM: Version: webpack 4.41.5
9:36:33 AM: Time: 29962ms
9:36:33 AM: Built at: 01/10/2020 2:36:28 PM
9:36:33 AM: Asset Size Chunks Chunk Names
9:36:33 AM: …/server/client.manifest.json 19.3 KiB [emitted]
9:36:33 AM: 082f8bb3bc4a3838f91f.js 171 KiB 1 [emitted] [immutable] commons.app
9:36:33 AM: 163f02748ee8e6a21769.js 11.9 KiB 2 [emitted] [immutable] pages/index
9:36:33 AM: 79c1499faa6f7996ffa4.js 533 KiB 4 [emitted] [immutable] [big] vendors.app
9:36:33 AM: LICENSES 1.88 KiB [emitted]
9:36:33 AM: c0ba4b1c35d0cbb3028d.js 39.5 KiB 0 [emitted] [immutable] app
9:36:33 AM: d75baa762e9ce79b6f5a.js 148 KiB 5 [emitted] [immutable] vendors.pages/index
9:36:33 AM: effcb98a4335f6bca3d6.js 2.33 KiB 3 [emitted] [immutable] runtime
9:36:33 AM: img/f075bf0.PNG 1.21 KiB [emitted]
9:36:33 AM: + 2 hidden assets
9:36:33 AM: Entrypoint app = effcb98a4335f6bca3d6.js 082f8bb3bc4a3838f91f.js 79c1499faa6f7996ffa4.js c0ba4b1c35d0cbb3028d.js
9:36:33 AM: WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
9:36:33 AM: This can impact web performance.
9:36:33 AM: Assets:
9:36:33 AM: 79c1499faa6f7996ffa4.js (533 KiB)
9:36:33 AM: Hash: 694d4a67684cde0616b8
9:36:33 AM: Version: webpack 4.41.5
9:36:33 AM: Time: 5522ms
9:36:33 AM: Built at: 01/10/2020 2:36:33 PM
9:36:33 AM: Asset Size Chunks Chunk Names
9:36:33 AM: e5cbfebca5a94172e3af.js 12.5 KiB 1 [emitted] [immutable] pages/index
9:36:33 AM: server.js 238 KiB 0 [emitted] app
9:36:33 AM: server.manifest.json 145 bytes [emitted]
9:36:33 AM: Entrypoint app = server.js
9:36:33 AM: :information_source: Generating pages
9:36:34 AM: ERROR /
9:36:34 AM: FetchError: invalid json response body at https://snobrumusa-com.myshopify.com/api/2019-10/graphql reason: Unexpected end of JSON input
9:36:34 AM: at /opt/build/repo/node_modules/node-fetch/lib/index.js:272:32
9:36:34 AM: at process._tickCallback (internal/process/next_tick.js:68:7)
9:36:34 AM: ERROR invalid json response body at https://snobrumusa-com.myshopify.com/api/2019-10/graphql reason: Unexpected end of JSON input
9:36:34 AM: at node_modules/node-fetch/lib/index.js:272:32
9:36:34 AM: at process._tickCallback (internal/process/next_tick.js:68:7)
9:36:34 AM: Skipping functions preparation step: no functions directory set
9:36:34 AM: Caching artifacts
9:36:34 AM: Started saving node modules
9:36:34 AM: Finished saving node modules
9:36:34 AM: Started saving pip cache
9:36:34 AM: Finished saving pip cache
9:36:34 AM: Started saving emacs cask dependencies
9:36:34 AM: Finished saving emacs cask dependencies
9:36:34 AM: Started saving maven dependencies
9:36:34 AM: Finished saving maven dependencies
9:36:34 AM: Started saving boot dependencies
9:36:34 AM: Finished saving boot dependencies
9:36:34 AM: Started saving go dependencies
9:36:34 AM: Finished saving go dependencies
9:36:34 AM: Build script success
9:36:34 AM: Starting to deploy site from ‘/dist’
9:36:34 AM: Creating deploy tree
9:36:34 AM: 3 new files to upload
9:36:34 AM: 0 new functions to upload
9:36:35 AM: Starting post processing
9:36:35 AM: Post processing done
9:36:35 AM: Site is live
9:36:59 AM: Finished processing build request in 1m24.012317649s

Does anyone have any ideas what could cause this?

Thank you.

EDIT: I do see the fetch error in the log, but this all works locally as well. Could this be the reason index.html isnt generated, and any idea why this would only happen on netlify?

hi there,

are you sure it’s not getting generated, or are your build settings pointing to the wrong place? this post and the responses might be helpful.