Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

TypeError: Nuxt is not a constructor #57

Open
daniel7912 opened this issue Jul 28, 2017 · 10 comments
Open

TypeError: Nuxt is not a constructor #57

daniel7912 opened this issue Jul 28, 2017 · 10 comments

Comments

@daniel7912
Copy link

daniel7912 commented Jul 28, 2017

Hi,

I am getting the error 'TypeError: Nuxt is not a constructor' on a fresh install when running 'npm run serve:dev'. Here are the steps I took:

  1. Install Adonis - npm i -g adonis-cli

  2. Create new install - adonis new --blueprint nuxt-community/adonuxt-template adonuxttest

  3. cd adonuxttest

  4. npm install

  5. npm run serve:dev

This is the complete terminal output:

`> [email protected] serve:dev /Users/Dan/Projects/adonuxttest

npm run dev

[email protected] dev /Users/Dan/Projects/adonuxttest
nodemon --watch app --watch bootstrap --watch config --watch .env -x node server.js

[nodemon] 1.11.0
[nodemon] to restart at any time, enter rs
[nodemon] watching: /Users/Dan/Projects/adonuxttest/app//* /Users/Dan/Projects/adonuxttest/bootstrap//* /Users/Dan/Projects/adonuxttest/config/**/* .env
[nodemon] starting node server.js
info adonis:framework +0ms serving app on localhost:3000
TypeError: Nuxt is not a constructor
at new NuxtController (/Users/Dan/Projects/adonuxttest/app/Http/Controllers/NuxtController.js:12:17)
at Object. (/Users/Dan/Projects/adonuxttest/app/Http/Controllers/NuxtController.js:26:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at requireStack (/Users/Dan/Projects/adonuxttest/node_modules/require-stack/src/index.js:44:12)
at Object.Ioc._autoLoad (/Users/Dan/Projects/adonuxttest/node_modules/adonis-fold/src/Ioc/index.js:178:18)
at Ioc.use (/Users/Dan/Projects/adonuxttest/node_modules/adonis-fold/src/Ioc/index.js:378:18)
at /Users/Dan/Projects/adonuxttest/server.js:19:3
at fold.Registrar.register.then (/Users/Dan/Projects/adonuxttest/bootstrap/http.js:105:9)
at process._tickCallback (internal/process/next_tick.js:109:7)
at Module.runMain (module.js:606:11)`

Node version - 6.11.0
Adonis version - 2.1.9

This question is available on Nuxt.js community (#c48)
@mekroth
Copy link

mekroth commented Jul 28, 2017

Hi,

have the same error.

Node version - 8.1.2
Adonis version - 2.1.8

@cawa-93
Copy link

cawa-93 commented Jul 29, 2017

What Nuxt version?

@mekroth
Copy link

mekroth commented Jul 29, 2017

Hi...

The problem is version 1.0.0-rc3 (package.json "nuxt": "^ 1.0.0-rc3").
With nuxt version 1.0.0-alpha.4 everything ok

@zangpakto
Copy link

zangpakto commented Jul 29, 2017

.then((nuxt) => {
this.nuxt = nuxt
if (config.dev) {
this.nuxt.build()
}
}

If you remove those lines from the NuxtController hopefully it should help, I had a similar issue. At least I think what I changed was the right thing to do :)

I started a new project without any changes on Tuesday night and it had a similar issue and found removing those lines to correct the issue.

my nuxt controller looks like

constructor () {
let config = Config.get('nuxt')
config.dev = Env.get('NODE_ENV') === 'development'
this.nuxt = new Nuxt(config)
}

  • render (request, response) {
    this.nuxt.render(request.request, response.response)
    }

@daniel7912
Copy link
Author

daniel7912 commented Jul 31, 2017

If I remove

.then((nuxt) => { this.nuxt = nuxt if (config.dev) { this.nuxt.build() } } then I still get the same error.

If I leave this code removed and then install [email protected], the app builds. I do get another error instead now but it's related to the logo.png file.

` ERROR Failed to compile with 1 errors 10:47:22 AM

error in ./resources/assets/img/logo.png

Module parse failed: /Users/Dan/Projects/adonuxttest/resources/assets/img/logo.png Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)

@ .//vue-loader/lib/template-compiler?{"id":"data-v-3e04842c","hasScoped":true,"preserveWhitespace":false}!.//vue-loader/lib/selector.js?type=template&index=0!./resources/layouts/error.vue 6:13-46
@ ./resources/layouts/error.vue
@ ./.nuxt/index.js
@ ./.nuxt/client.js
@ multi webpack-hot-middleware/client?reload=true ./.nuxt/client.js`

Edit: Just realised this error is already reported (#45)

@zangpakto
Copy link

In the config nuxt file just add the loader if it is missing.

build: {
loaders: [
{
test: /.(png|jpe?g|gif|svg)$/,
loader: 'url-loader',
query: {
limit: 10000, // 10KO
name: 'img/[name].[hash].[ext]'
}
}
]
}

@ConsoleTVs
Copy link

Same. Fresh installation.

image

@mnismt
Copy link

mnismt commented Aug 2, 2017

I have same errors.

wongni pushed a commit to wongni/adonuxt-template that referenced this issue Aug 3, 2017
@wongni
Copy link

wongni commented Aug 3, 2017

Refer to the pull request here #59

@wongni
Copy link

wongni commented Aug 7, 2017 via email

atinux added a commit that referenced this issue Aug 14, 2017
#57: Fix 'Nuxt is not a constructor' error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants