Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Can't resolve '@date-io/date-fns'

I'm using React Material UI and I get this error : Module not found: Can't resolve '@date-io/date-fns'.

Here are the dependencies that I have in my package.json file :

"dependencies": {
    "@date-io/date-fns": "^2.0.0",
    "@material-ui/core": "^4.9.5",
    "@material-ui/pickers": "^3.2.10",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "axios": "^0.19.2",
    "date-fns": "^2.0.0",
    "react": "^16.13.0",
    "react-dom": "^16.13.0",
    "react-facebook-login": "^4.1.1",
    "react-google-login": "^5.1.14",
    "react-google-maps": "^9.4.5",
    "react-hook-form": "^5.2.0",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.0"
  },

I tried installing the last version of date-io/date-fns, then tried the version 2.0.0 and version 1.0.0 and I still get the same error.

like image 414
Ala Ben Aicha Avatar asked May 15 '20 15:05

Ala Ben Aicha


People also ask

Can t resolve'@ date io date-fns in?

To solve the error "Module not found: Error: Can't resolve '@date-io/date-fns'", make sure to install the package by opening your terminal in your project's root directory and running the command npm install @date-io/date-fns date-fns and restart your development server.

What is date Io date-FNS?

Abstraction over common JavaScript date management libraries. The project exposes an abstraction interface over luxon, date-fns v2, dayjs and moment. It allows you to build any UI date or time components, while utilizing the same date management library in use within your user's project.


2 Answers

$ npm i date-fns@next @date-io/[email protected]
reference:
https://github.com/mui-org/material-ui-pickers/issues/240
https://github.com/dmtrKovalenko/date-io/issues/33

Reference: https://material-ui-pickers.dev/getting-started/installation#peer-library

Important: For material-ui-pickers v3 use v1.x version of @date-io adapters.

npm i @date-io/[email protected] date-fns
// or
npm i @date-io/[email protected] moment
// or
npm i -s @date-io/[email protected] luxon
// or
npm i -s @date-io/[email protected] dayjs
like image 116
user120242 Avatar answered Oct 24 '22 04:10

user120242


You can check this Commands...

yarn add date-fns

or

npm i date-fns
like image 24
Mahmud Hasan Avatar answered Oct 24 '22 05:10

Mahmud Hasan