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.

UniversalRouter not working on docker release build

See original GitHub issue

Hi everyone,

I’m having an issue making the new version of UniversalRouter implementation working with a docker build on release…

The issue is the following one :

/app/build/webpack:/src/core/router.js:13
const router = new Router(routes)
               ^
TypeError: __WEBPACK_IMPORTED_MODULE_0_universal_router___default.a is not a constructor
    at Object.<anonymous> (/app/build/webpack:/src/core/router.js:13:16)
    at __webpack_require__ (/app/build/webpack:/webpack/bootstrap 2017df5206f6ff8da90a:19:1)
    at Object.<anonymous> (/app/build/server.js:1335:72)
    at __webpack_require__ (/app/build/webpack:/webpack/bootstrap 2017df5206f6ff8da90a:19:1)
    at Object.<anonymous> (/app/build/server.js:9733:18)
    at __webpack_require__ (/app/build/webpack:/webpack/bootstrap 2017df5206f6ff8da90a:19:1)
    at /app/build/webpack:/webpack/bootstrap 2017df5206f6ff8da90a:65:1
    at Object.<anonymous> (/app/build/server.js:71:10)
    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.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
error Command failed with exit code 1.

It works completely fine in development and when building it with the same command found in my docker-compose.yml which is yarn run build -- --release --docker && node build/server.js but it makes the container to exit on my server…

I’m requiring my routes the same way the boilerplate does and I’m on the branch feature/react-intl (merged with Apollo client) just so you know.

If you new some code I’ll post it right away. Meanwhile I’ll try fixing this… 😅

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hxuanhungcommented, Sep 26, 2017

Fixed for me with:

import UniversalRouter from 'universal-router/main';
1reaction
frenzzycommented, Sep 26, 2017

Is this error for client-side or server-side build? React Starter Kit version? Node.js version? Universal Router version? Have you tried this update? https://github.com/kriasoft/react-starter-kit/pull/1403 Also you can try to import this way:

import UniversalRouter from 'universal-router/browser.js'; // for client-side code
import UniversalRouter from 'universal-router/main.js';    // for server-side code
import UniversalRouter from 'universal-router/legacy.js';  // for Node.js v5 and below
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with Angular Universal Docker build - Stack Overflow
I'm not sure if this is still relevant.. but you can try replacing your dockerfile with the following: ### Stage: 1 ### FROM...
Read more >
Docker container crash while performing an "npm install ...
I have setup a docker container using a debian:latest image and installed node v 5.10.1 and npm 3 in it.
Read more >
Top 5 universal-router Code Examples | Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Make slim Rails Docker images - DEV Community ‍ ‍
We have a two-step building process starting from a ruby:alpine image. First stage. In the first stage, size is not of utmost importance:...
Read more >
Micro Frontends - extending the microservice idea to frontend ...
Techniques, strategies and recipes for building a modern web app with multiple teams ... there are still a few implementation problems in some...
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