Home

Issue: 3080

Error: bundle export should be a function when using { runInNewContext: false }

[issue link]

I’m just starting with Nuxt.js, tried to start from a template
vue init nuxt-community/typescript-template front
and changed srcDir to srcDir: './front/'. Then I copied things that looked important from front/package.json and front/tsconfig.json one level up.

The process wasn’t very straightforward so I might have made a mistake somewhere. Anyway, now it compiles and starts fine using “nuxt” command, but when I open the page localhost:3000, it displays a NuxtServerError page with nice debug info. The server console says:

{ Error: bundle export should be a function when using { runInNewContext: false }.
    at j:\types\CML\node_modules\vue-server-renderer\build.js:8401:17
    at new Promise (<anonymous>)
    at j:\types\CML\node_modules\vue-server-renderer\build.js:8388:14
    at Object.renderToString (j:\types\CML\node_modules\vue-server-renderer\build.js:8564:9)
    at Renderer.renderRoute (j:\types\CML\node_modules\nuxt\lib\core\renderer.js:344:41)
    at Renderer.nuxtMiddleware (j:\types\CML\node_modules\nuxt\lib\core\middleware\nuxt.js:12:31)
    at call (j:\types\CML\node_modules\connect\index.js:239:7)
    at next (j:\types\CML\node_modules\connect\index.js:183:5)
    at SendStream.error (j:\types\CML\node_modules\nuxt\node_modules\serve-static\index.js:121:7)
    at emitOne (events.js:116:13)
    at SendStream.emit (events.js:211:7)
    at SendStream.error (j:\types\CML\node_modules\nuxt\node_modules\send\index.js:270:17)
    at SendStream.onStatError (j:\types\CML\node_modules\nuxt\node_modules\send\index.js:421:12)
    at next (j:\types\CML\node_modules\nuxt\node_modules\send\index.js:764:28)
    at j:\types\CML\node_modules\nuxt\node_modules\send\index.js:772:23
    at FSReqWrap.oncomplete (fs.js:152:21) statusCode: 500, name: 'NuxtServerError' }

This is the content of runner, entry, files, basedir and runInNewcontext just before the error:

runner =  {}
entry= server-bundle.js
basedir= j:\types\CML
runInNewcontext= false
files={'pages_index.js': 'exports.ids = [0]; exports.modules = {/***/ 56:/***/ (function(...' ,
       'layouts_default.js': 'exports.ids = [1]; exports.modules = {/***/ 58:/***/ (function...' ,
       'server-bundle.js': 'module.exports =/******/ (function(modules) {...'   }

I have no idea what’s going on. As I said, I started using Nuxt yesterday and probably stop today.

IMHO, the framework would greatly benefit from improved error messages.

This question is available on Nuxt.js community (#c2666)