question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Example with micro as custom server

See original GitHub issue

I am trying to combine three awesome Zeit projects (next.js + micro + now). While putting next on top of micro I keep getting errors. Did anyone make it work?

This is my example code

const next = require('next')
const { parse } = require('url')
const dispatch = require('micro-route/dispatch')

const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

const defaultRoute = async function (req, res) {
  return { say: 'Hello' }
}

module.exports = dispatch()
  .dispatch('/api', '*', defaultRoute )
  .otherwise((req, res) => {
    const parsedUrl = parse(req.url, true)
    handle(req, res, parsedUrl)
  })

Error after running npm start and requesting http://localhost:3000/

TypeError: Cannot read property 'hasErrors' of null
    at HotReloader.getCompilationErrors (/projects/node_modules/next/dist/server/hot-reloader.js:525:23)
    at Server.getCompilationError (/projects/node_modules/next/dist/server/index.js:1012:37)
    at Server._callee16$ (/projects/node_modules/next/dist/server/index.js:742:39)
    at tryCatch (/projects/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/projects/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (/projects/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at F (/projects/node_modules/core-js/library/modules/_export.js:35:28)
    at Server.<anonymous> (/projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Server.renderToHTML (/projects/node_modules/next/dist/server/index.js:786:23)
    at Server._callee15$ (/projects/node_modules/next/dist/server/index.js:708:29)
    at tryCatch (/projects/node_modules/regenerator-runtime/runtime.js:65:40)
    at Generator.invoke [as _invoke] (/projects/node_modules/regenerator-runtime/runtime.js:303:22)
    at Generator.prototype.(anonymous function) [as next] (/projects/node_modules/regenerator-runtime/runtime.js:117:21)
    at step (/projects/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sergiodxacommented, May 9, 2017

Are you running app.prepare()? I don’t see it in your code. Check -> https://github.com/zeit/next.js/blob/master/examples/custom-server/server.js#L9-L10

0reactions
fabien88commented, May 18, 2017

Nice one, thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Micro Frontends - extending the microservice idea to frontend ...
Extending the microservice idea to frontend development. Techniques, strategies and recipes for building a modern web app with multiple teams that can ship ......
Read more >
Building a Micro-frontend Framework - Toptal
Micro -frontend architectures decompose a front-end app into semi-independent "microapps" working loosely together, making large projects more manageable.
Read more >
Micro Frontends - Martin Fowler
Figure 6: Each of these servers can be built and deployed to independently. This example shows how micro frontends is not necessarily a...
Read more >
5 Ways to Deploy Microservices - Semaphore CI
From VMs to Kubernetes and Serverless, there are many ways of to deploy microservices. The perfect method is determined by size and scaling ......
Read more >
aol/micro-server: Microserver is a Java 8 native, zero ... - GitHub
Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found