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.

TypeError: (0 , _moment2.default) is not a function

See original GitHub issue

I’m trying to use antd as a component library with my existing build system (webpack 2). Can I use components from this library without importing the entire build system? I did

npm install antd

and in my page, added

import { DatePicker } from 'antd'

export function Page(){
  return <DatePicker/>
}

Error

Uncaught TypeError: (0 , _moment2.default) is not a function
    at Function.getDefaultProps (?d41d*:78)
    at Object.createClass (ReactClass.js:675)
    at Object../node_modules/rc-time-picker/lib/Panel.js (?d41d*:45)
    at __webpack_require__ (bootstrap d2f4533…:689)
    at fn (bootstrap d2f4533…:110)
    at Object../node_modules/antd/lib/date-picker/wrapPicker.js (wrapPicker.js:21)
    at __webpack_require__ (bootstrap d2f4533…:689)
    at fn (bootstrap d2f4533…:110)
    at Object../node_modules/antd/lib/date-picker/index.js (index.js:23)
    at __webpack_require__ (bootstrap d2f4533…:689)

Environment

webpack 2 Antd 2.4.3 Node 7 OSX 10.10

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:25 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
deveeduttacommented, Dec 29, 2016

@KhushbooTaneja This alias has to be added in the webpack configuration. details.

  resolve: {
    modules: ['app', 'node_modules'],
    extensions: [
      '',
      '.js',
      '.jsx',
      '.react.js',
    ],
    mainFields: [
      'jsnext:main',
      'main',
    ],
    alias: {
      // required for moment to work properly
      moment: 'moment/moment.js',
    }
  },
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: _moment2.default.date is not a function ...
When I call Moment just in the render() function, I don't get this error. But, I need the date information in the state...
Read more >
(0 , import_defineToJSON.default) is not a function - Bugs
When trying to import '@8base/auth' to a Vite+Vue 3 project, the following error is trigger by the import statement. Uncaught TypeError: (0 ......
Read more >
Uncaught TypeError: _moment2.default.date is not a function ...
Coding example for the question Uncaught TypeError: _moment2.default.date is not a function in React app-Reactjs.
Read more >
typeerror: (0 , express_1.default) is not a function - You.com
I'm getting [TypeError: (0 , express_1.default) is not a function for my code. import express from "express"; const app = express (); //...
Read more >
TypeError - (0 , _requireHook).default is not a function
I'm getting TypeError: (0 , _requireHook).default is not a function at Object.
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