React-datepicker: Module not found: Can't resolve 'moment' in '/Users/xxx/react/project_name/node_modules/react-datepicker/es'

Created on 20 Aug 2018  路  3Comments  路  Source: Hacker0x01/react-datepicker

I installed the momentjs using "npm i react-moment --save"
My moments js is installed in node_modules/react-moment
Should I import
import moment from 'react-moment';
or
import moment from 'moment'; (this is given in example)
Although both are not working, I get the same error!

Expected behavior

Should be able to import react correctly

Actual behavior

Gives module not found error

Steps to reproduce

Installed datepicker using npm
installed momentjs using npm
Still getting this error

All 3 comments

Did you restarted your builder watch mode?

I had the same issue with the following dependencies:

"dependencies": { "firebase": "^5.4.1", "moment": "^2.22.2", "react": "^16.4.2", "react-datepicker": "^1.6.0", "react-dom": "^16.4.2", "react-loadable": "^5.5.0", "react-moment": "^0.7.9", "react-router": "^4.3.1", "react-router-dom": "^4.3.1", "react-scripts": "1.1.5" },

After deleting the node_modules and a fresh npm install it seems to work

Moment.js was removed in #1527, starting v2.0.0, this package doesn't use Moment anymore.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carmouche picture carmouche  路  3Comments

arturictus picture arturictus  路  3Comments

kkras3 picture kkras3  路  3Comments

flaurida picture flaurida  路  3Comments

lclemence picture lclemence  路  3Comments