adonuxt-template icon indicating copy to clipboard operation
adonuxt-template copied to clipboard

TypeError: Nuxt is not a constructor

Open daniel7912 opened this issue 8 years ago • 10 comments

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)

daniel7912 avatar Jul 28 '17 21:07 daniel7912

Hi,

have the same error.

Node version - 8.1.2 Adonis version - 2.1.8

mekroth avatar Jul 28 '17 22:07 mekroth

What Nuxt version?

cawa-93 avatar Jul 29 '17 06:07 cawa-93

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

mekroth avatar Jul 29 '17 07:07 mekroth

.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) }

zangpakto avatar Jul 29 '17 22:07 zangpakto

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)

daniel7912 avatar Jul 31 '17 09:07 daniel7912

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]' } } ] }

zangpakto avatar Jul 31 '17 10:07 zangpakto

Same. Fresh installation.

image

ConsoleTVs avatar Aug 01 '17 12:08 ConsoleTVs

I have same errors.

mnismt avatar Aug 02 '17 01:08 mnismt

Refer to the pull request here https://github.com/nuxt-community/adonuxt-template/pull/59

wongni avatar Aug 03 '17 19:08 wongni

Hi Thanh,

I can't find your comment in Github. Did you remove it?

On Fri, Aug 4, 2017 at 9:09 AM, Thanh Minh [email protected] wrote:

@wongni https://github.com/wongni Thanks you, but i have new errors:

Error: Cannot find module 'es6-promise\auto' from 'C:\OpenServer\domains\face.io' at Function.module.exports [as sync] (C:\OpenServer\domains\face.io\node_modules\resolve\lib\sync.js:40:15) at r (C:\OpenServer\domains\face.io\node_modules\vue-server-renderer\build.js:7741:44) at Object. (webpack:/external "es6-promise/auto":1:0) at webpack_require (webpack:/webpack/bootstrap b723638754f17ec59ca0:25:0) at Object. (server-bundle.js:1358:75) at webpack_require (webpack:/webpack/bootstrap b723638754f17ec59ca0:25:0) at Object. (server-bundle.js:996:65) at webpack_require (webpack:/webpack/bootstrap b723638754f17ec59ca0:25:0) at server-bundle.js:92:18 at Object. (server-bundle.js:95:10) at evaluateModule (C:\OpenServer\domains\face.io\node_modules\vue-server-renderer\build.js:7747:21) at C:\OpenServer\domains\face.io\node_modules\vue-server-renderer\build.js:7805:18 at Promise () at C:\OpenServer\domains\face.io\node_modules\vue-server-renderer\build.js:7797:14 at Object.renderToString (C:\OpenServer\domains\face.io\node_modules\vue-server-renderer\build.js:7951:9) at P (C:\OpenServer\domains\face.io\node_modules\nuxt\node_modules\pify\index.js:49:6)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/adonuxt-template/issues/57#issuecomment-320244602, or mute the thread https://github.com/notifications/unsubscribe-auth/AK_oVXJJzUw0hSsvVhyZzh2H4-9zOvEZks5sUxgfgaJpZM4OnFsA .

wongni avatar Aug 07 '17 13:08 wongni