bluebeel / now-nuxt

A Now v2 Nuxt builder
25 stars 1 forks source link

in dev mode, nuxt.config.js not work. #5

Closed Chaoyingz closed 5 years ago

Chaoyingz commented 5 years ago

hello, I set nuxt project like this https://github.com/bluebeel/now-nuxt/issues/4#issuecomment-451666759, but when I run yarn run dev, nuxt.config.js not work. how to solve it.

bluebeel commented 5 years ago

I just tested with one of my project. it work normally. Can you show us your nuxt.config.js

Chaoyingz commented 5 years ago

https://files-k3vht3cuc.now.sh

bluebeel commented 5 years ago

The error you got? You are using nuxt or nuxt-egde and version?

Chaoyingz commented 5 years ago

nuxt version: 2.3.4 In index.vue:

async asyncData({ app }) {
  const { data } = await app.$axios.get('/topics/hot.json')

  return {
    topics: data
  }
}

i got error like this:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined

in context app, $axios is not found.

bluebeel commented 5 years ago

Update your dependency @nuxtjs/axios to latest

async asyncData({ $axios }) {
  const ip = await $axios.get('/topics/hot.json')
  return {
    topics: data
  }
}
Chaoyingz commented 5 years ago

in package.json

"@nuxtjs/axios": "^5.3.6",

in index.vue

 async asyncData({ $axios }) {
    console.log($axios)
    const ip = await $axios.$get('http://icanhazip.com')
    return { ip }
  }

got error:

undefined
Cannot read property '$get' of undefined

When I deleted asyncData method, The page loads successfully, but Global CSS is not load. So nuxt.config.js is not work.

bluebeel commented 5 years ago

You put again the $ in front of get. Remove it

Chaoyingz commented 5 years ago
Cannot read property 'get' of undefined
Chaoyingz commented 5 years ago

sorry, I found the isseus, my project nuxt version is not least.

Chaoyingz commented 5 years ago

Use create-nuxt-app create project, the default package.json is

"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",

Change it to

"dev": "nuxt",