skip to Main Content

I am building a NextJS app and all of a sudden all my import aliases stopped working

This is my jsconfig.json

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

I have an initial import like this in my layout.jsx file:

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

And that stopped working completely.

I had to go through my project and use absolute paths so I turned that into:

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

And everything is loading but does anyone have any ideas what happened? I can’t get my alias to work now.

Im using Linux, Visual Studio Code, Nginx, on a DO Droplet.

I tried to use @/components/RootLayout but received a Module not found – my aliases broke and they had been working for days before?

2

Answers


  1. Also seeing this all of a sudden starting today…

    Here is my jsconfig.json:

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

    I can’t for the life of me figure out why this is happening…

    Login or Signup to reply.
  2. this happened to me too, what i did was deleting node-modules and npm i again , that solved the issue, i’m not sure why this happened exactly but i guess it is because my computer is old and slow so it caused errors to happen.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search