【问题标题】:Changing the file name causes an error when deploying Vercel部署 Vercel 时更改文件名会导致错误
【发布时间】:2021-07-26 23:30:40
【问题描述】:

当我更改文件名时,部署 Vercel 时会出现错误。 我受到了影响

components/NavBar.tsx

pages/ThankYou.tsx

文件。

在最初使用上述名称进行部署后,我已将所有文件名对齐为小写,因此我不得不重命名

components/navbar.tsx

pages/thankyou.tsx

并部署它们。

我收到如下图所示的错误,并且部署失败。

文字版:

21:59:05.755    https://nextjs.org/telemetry
21:59:05.809    info  - Checking validity of types...
21:59:13.352    Failed to compile.
21:59:13.353    ./pages/about-iq.tsx:7:20
21:59:13.353    Type error: Cannot find module '../components/navbar' or its corresponding type declarations.
21:59:13.353       5 | import { useRouter } from 'next/router';
21:59:13.353       6 | 
21:59:13.353    >  7 | import NavBar from '../components/navbar';
21:59:13.353         |                    ^
21:59:13.353       8 | import Footer from '../components/footer';

thankyou.tsx 是一个页面,所以此时没有错误,但是当我再次将其重命名为NavBar.tsx 并部署它,并访问domain/thankyou 时,我得到了404 错误。 此时,当我访问domain/ThankYou时,就可以访问了。

我以为是vercel的缓存功能造成的,尝试了Redeploy,但是没有用。 我也尝试删除 node_modules、.next 和 package-lock.json,但无济于事。

如果您知道任何策略,请告诉我。 提前致谢。

PS: 谢谢你的回答! 这是否意味着它正在检测变化?

【问题讨论】:

标签: next.js


【解决方案1】:

Vercel deploy / build fail. "Failed to compile. Type error: Cannot find module ... or its corresponding type declarations

我用A先生提出的这个问题来完善它。

我修复后的错误信息是一样的! 我在 github 上有修复日志,但我仍然无法到达那里。

我重命名了目录,将其推送,然后再次将其推送回来,它恢复正常。 我把pages目录放到src目录下并修复了。

【讨论】:

    猜你喜欢
    • 2013-04-03
    • 2016-03-12
    • 2011-05-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 1970-01-01
    • 2022-01-01
    • 2020-08-13
    相关资源
    最近更新 更多