Create react app Error: Cannot find module './locale'

前端 未结 5 1583
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 08:15

I bootstrapped my application with create-react-app and when I run my app it compiles with warnings and it throws errors on the browser.

Error while com

相关标签:
5条回答
  • 2020-12-17 08:50

    The reason this happens is because moment has released the new version from 2.24.0 to 2.25.0

    Perform the following Steps to solve this issue :

    Step 1: change the versions (In your case just add the "moment":"2.24.0" to your dependencies in your package.json since I don't see it present in your package.json)

    "moment": "2.24.0",
    "moment-timezone": "^0.5.28",
    

    Step 2: If you are using yarn please add resolutions in your package.json file like this

    "dependencies" {
    "moment": "2.24.0",
    "moment-timezone": "^0.5.28"
    },
    "resolutions": {
    "moment": "2.24.0"
    },
    

    For more information about this issue go to https://github.com/moment/moment/issues/4505

    0 讨论(0)
  • 2020-12-17 08:55

    Change in package.json :

    "moment": "2.25.1",
    

    to

    "moment": "2.24.0",
    

    then run on terminal: npm install

    0 讨论(0)
  • 2020-12-17 08:55

    Just follow these steps:-

    step 1: npm install --save-dev npm-force-resolutions

    step 2: add in package.json

    "resolutions": {
        "moment": "2.24.0"
     }
    

    step 3: add in scripts in package.json

    "preinstall": "npx npm-force-resolutions"
    

    step 4: npm install

    0 讨论(0)
  • 2020-12-17 09:03

    Moment Released new version that breaks application,

    as in your case there is no moment in package.json, if you simply add this to your package

    moment: "2.24.0"

    and run npm install it will add this moment package and resolve your issue,

    otherwise you can try this cammand

    npm install --save --save-exact moment@2.24.0
    

    it will automatically add this package to your package.json with this specific version

    i hope this works for you

    0 讨论(0)
  • 2020-12-17 09:09

    New moment 2.25.x versions have been released and the latest version should fix this issue.

    It seems like the version 2.25.2 was addressing this issue. So a downgrade to 2.24.0 is not required anymore.

    0 讨论(0)
提交回复
热议问题