首页 > 解决方案 > 在反应应用程序中更新反应脚本后出错

问题描述

在我的节点应用程序中将 react-scripts 升级到 ^3.0.0 后出现此错误 -

 FAIL  src/components/App/index.test.js
    ● Test suite failed to run

    Cannot find module 'date-fns/addDays' from 'date-fns-utils.js'

    However, Jest was able to find:
        './index.css'
        './index.js'
        './index.test.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:230:17)
      at Object.<anonymous> (node_modules/material-ui-pickers/utils/date-fns-utils.js:8:39)

我已经手动安装和更新date-fns了,并且无法找到与此问题直接相关的任何重大更改。(对 npm 很陌生并做出反应)。

标签: reactjsnpmreact-scripts

解决方案


推荐阅读