别名导入突然导致 NextJS 出现 Module Not Found 错误

问题描述 投票:0回答:1

我正在构建一个 NextJS 应用程序,突然间我的所有导入别名都停止工作了

这是我的jsconfig.json

{
    "compilerOptions": {
      "baseUrl": ".",
      "paths": {
        "@/*": ["./*"]
      }
    }
  }

我的layout.jsx 文件中有一个像这样的初始导入:

import {RootLayout} from '@/components/RootLayout';

那完全停止工作了。

我必须浏览我的项目并使用绝对路径,所以我将其变成:

import {RootLayout} from '/src/components/RootLayout';

一切都在加载,但有人知道发生了什么吗?我现在无法使用我的别名。

我在 DO Droplet 上使用 Linux、Visual Studio Code、Nginx。

我尝试使用

@/components/RootLayout
但收到了
Module not found
- 我的别名坏了,他们之前已经工作了好几天了?

reactjs next.js import module alias
1个回答
0
投票

今天开始也突然看到这个...

这是我的jsconfig.json:

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "@/*": ["./*"]
        }
    }
}

我一生都无法弄清楚为什么会发生这种情况......

© www.soinside.com 2019 - 2024. All rights reserved.