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.

Require is not defined - react-datepicker.min.js

See original GitHub issue

Fresh install, typical React project:

npm install react-datepicker --save

import DatePicker from 'react-datepicker';

Pages crashes with

react-datepicker.min.js?1928:1 Uncaught ReferenceError: require is not defined

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
tsureladcommented, Mar 30, 2016

Webpack usually has the configuration:

  module: {
    noParse: /\.min\.js/
  }

so the file react-datepicker/dist/react-datepicker.min.js is not being parsed. This file uses the require function which is NodeJS specific function.

3reactions
kostik-noircommented, Oct 18, 2016

use import DatePicker from 'react-datepicker/dist/react-datepicker';

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - React-DatePicker - Format not Defined - Stack Overflow
I would take a look to see if that's the format function you would want to use or write your own format function...
Read more >
react-datepicker - npm
A simple and reusable datepicker component for React. Latest version: 4.8.0, last published: 7 months ago. Start using react-datepicker in ...
Read more >
Integrating with Other Libraries - React
It determines updates based on its own internal representation, and if the same DOM nodes are manipulated by another library, React gets confused...
Read more >
Datepicker is not defined as function - CodeProject
In the browser, check the developer tools window and see if the bootstrap-datetimepicker.min.js file is actually being found and loaded.
Read more >
Top 5 react-datepicker Code Examples - Snyk
css'; // tslint:disable-next-line:no-var-requires // const data = require('../data/style.json'); // tslint:disable-next-line:no-var-requires const DatePicker = ...
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