簡體   English   中英

npm審核修復后找不到模塊“ date-fns”

[英]Cannot find Module 'date-fns' After npm audit fix

在運行npm audit fix之前,我的npm audit fix應用程序運行良好。 我現在收到一個錯誤:

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'].

npm test期間的其中一項npm test

這可能是什么? 讓我知道我需要添加哪些細節。 謝謝!

我建議您刪除:node_modules和package-lock.json並運行npm install。

也許您可以嘗試顯式下載date-fns庫,並查看它是否擺脫了當前的錯誤消息:

從'date-fns-utils.js'中找不到模塊'date-fns / addDays'

這表明問題是由於無法在date-fns軟件包中找到addDays模塊引起的。 我懷疑npm audit fix可能在安裝date-fns庫的最新版本時出現問題。

也許您可以嘗試以下方法,看看是否可以解決您的問題:

rm package-lock.json
npm i -S date-fns 

# or with yarn
yarn add date-fns

希望有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM