Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #3520
Closed
Open
Issue created Nov 29, 2017 by Administrator@rootContributor

.mjs node module not working after eject

Created by: Kingdutch

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

Unsure, using yarn 0.27.5

Which terms did you search for in User Guide?

webkit, constructor

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_universal_router___default.a is not a constructor

Environment

  1. node -v: v8.2.1
  2. npm -v: 5.3.0
  3. yarn --version (if you use Yarn): 0.27.5
  4. npm ls react-scripts (if you haven’t ejected): [ejected]

Then, specify:

  1. Operating system: Mac OS X High Sierra
  2. Browser and version (if relevant): Chrome Version 62.0.3202.94 (Official Build) (64-bit)

Steps to Reproduce

(Write your steps here:)

  1. Use create-react-app to create a new react app
  2. Eject the react app
  3. Install "Universal Router" using yarn (yarn add universal-router)
  4. Add the following lines to your src/index.js
import UniversalRouter from 'universal-router';
console.log(UniversalRouter);
const router = new UniversalRouter([]);

Expected Behavior

The console output should show that UniversalRouter is a proper constructor function and no errors should occur.

Actual Behavior

The console outputs /static/media/browser.99d6d764.mjs and the following error is shown: TypeError: __WEBPACK_IMPORTED_MODULE_1_universal_router___default.a is not a constructor

image

Possible fix

I found that the following fixed this for me: On line 201 of the generated webpack.config.dev.js replace: exclude: [/\.js$/, /\.html$/, /\.json$/], with exclude: [/\.m?js$/, /\.html$/, /\.json$/],

This might also need to be done for the .prod version.

Assignee
Assign to
Time tracking