Nuxt.js: nuxt generate cause connect ECONNREFUSED error

Created on 3 Dec 2018  路  2Comments  路  Source: nuxt/nuxt.js

Version

v2.3.4

Reproduction link

https://codesandbox.io/s/38n4nxkn76

Steps to reproduce

  1. create nuxt starter
  2. use axios to current path (axios.get("/user.json"))
  3. try to generate static files

What is expected ?

Complete static files

What is actually happening?

Error

 ERROR   /                                                                                         23:22:09

Error: connect ECONNREFUSED 127.0.0.1:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)


 ERROR  connect ECONNREFUSED 127.0.0.1:3000                                                        23:22:09

  at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)

This bug report is available on Nuxt community (#c8266)
bug-report

Most helpful comment

@manniL Wasn't the server running on version 2.1.0 and below?

All 2 comments

While generating your app no server is running (compared to SSR mode).

What you want to do then is either requiring the json manually (which should be fine) or using a mounted hook (but then the info isn't included in the HTML)

Example (would probably move it to assets):

import data from '~/static/data.json'
export default {

  data: () => {
    return {
      ...data,      
      show: true
    }
  },

@manniL Wasn't the server running on version 2.1.0 and below?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieloprado picture danieloprado  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

shyamchandranmec picture shyamchandranmec  路  3Comments

o-alexandrov picture o-alexandrov  路  3Comments