[英]Cannot find Module 'date-fns' After npm audit fix
My react app was working fine until I ran npm audit fix
. 在运行
npm audit fix
之前,我的npm audit fix
应用程序运行良好。 I am now getting an error: 我现在收到一个错误:
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'].
On one of the tests during npm test
在
npm test
期间的其中一项npm test
What could this be? 这可能是什么? Let me know what details I need to add.
让我知道我需要添加哪些细节。 Thanks!
谢谢!
我建议您删除:node_modules和package-lock.json并运行npm install。
Maybe you could try explicitly downloading the date-fns
library and seeing if this gets rid of your current error message of: 也许您可以尝试显式下载
date-fns
库,并查看它是否摆脱了当前的错误消息:
Cannot find module 'date-fns/addDays' from 'date-fns-utils.js'
从'date-fns-utils.js'中找不到模块'date-fns / addDays'
which indicates that the issue is due to being unable to locate the addDays
module within the date-fns
package. 这表明问题是由于无法在
date-fns
软件包中找到addDays
模块引起的。 I suspect npm audit fix
may have had an issue installing the more up-to-date version of the date-fns
library. 我怀疑
npm audit fix
可能在安装date-fns
库的最新版本时出现问题。
Perhaps you could try the following and seeing if this resolves your issue: 也许您可以尝试以下方法,看看是否可以解决您的问题:
rm package-lock.json
npm i -S date-fns
# or with yarn
yarn add date-fns
Hopefully that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.