How to troubleshoot Path Intellisense in VScode when using jsconfig.json for Next.js

In the structure of my project, it looks like this:

jsconfig.json
next.config.json
components
   |_atoms
       |_Button.jsx
       |_Button.module.scss
       |_...
   |_...
...

Within the jsconfig.json file, I have specified the following settings:

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

   "include": ["components/**/*", "api/**/*", "data/**/*", "pages/**/*", "utils/**/*"]
}

Although Next.js successfully imports the components and everything is functioning, the autocomplete feature is no longer working during development.

For instance, all these import statements are functioning properly, yet I had to manually type out the paths because autocomplete didn't provide suggestions:

import Button from "components/atoms/Button";    //works
import Button from "@/components/atoms/Button";  //works
import Button from "../components/atoms/Button"; //works if relative path is correct
import styles from "./Button.module.scss";       //works within Button.jsx

While there seems to be no issue with Next.js, the Path Intellisense extension isn't suggesting filenames anymore. I even tried renaming the jsconfig.json file to something else to disable it, which resulted in Path Intellisense functioning correctly but then Next.js couldn't import components.

I'm looking for a solution that allows me to benefit from both absolute imports and also use Path Intellisense. How can I achieve this?

Answer №1

If you have recently updated your jsconfig.json (or tsconfig.json) file, or if you have just created a new one, you will need to follow these steps to ensure it works correctly:

First, restart the server (if using nextjs). Then, restart VSCode in order to enable autocomplete.

To summarize,

  • Stop the server
  • Restart VSCode
  • Start the server

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Update input field value with data retrieved via ajax call in AngularJS

My current approach involves using AngularJS directives for Bootstrap in order to create an edit form on a Bootstrap modal when the user clicks on the edit button from a list of items. Here is the code I have implemented: HTML: <div class="modal-heade ...

Comparing Two Arrays in AngularJS and Disabling on Identical Cases

I currently have two tables: "Available subject" and "Added subject" which are populated by ng-repeat with two separate lists of objects. My objective is to accomplish three things: 1 - When the user clicks on the plus sign, a row with identical content s ...

What is the best way to determine in component.html whether the column type is equal to 1 to show the label text "Active,"

Having trouble checking the value of an object named ReportControl. If the column type is 1, display the label "active"; otherwise, display the label "not active" on reportcomponent.html. The data for the ReportControl object is as follows: {"reportId": ...

What are the steps to turn off response data compression in an Express server?

How can I receive the 'Content-Length' response from the server without gzip compression enabled? I am using a compression middleware for this purpose: const shouldCompress = (req, res) => { if(req.headers['x-no-comprassion']) { ...

What steps can I take to prevent Internet Explorer from caching my webpage?

After implementing Spring MVC for Angular JS on the front end, I encountered an issue where logging in with different user credentials resulted in incorrect details being displayed. This problem only occurred in Internet Explorer, requiring me to manually ...

Prevent the display of hyperlinks in the status bar when hovering over a hyperlink or button

The application I'm working on has a default status bar at the bottom of each screen that displays URLs linked to buttons and icons. For example: https://i.stack.imgur.com/ZFTsp.jpg I am trying to prevent the display of URLs associated with hyperlin ...

Having trouble with updating AngularJS?

I am facing an issue while updating the guitar object in my AngularJS application. The operation is performed using the updateGuitar controller with ngMock backend. After updating the guitar object, the put request is processed by the carService. However, ...

Is there a resource available that can help me create a jquery/ajax image slider/carousel similar to this?

One thing that really caught my eye is how cnn.com has implemented this feature. I think it would be a great addition to the website I'm currently working on. I particularly like the page numbering, as well as the first, previous, next, and last butto ...

What are the best techniques for creating animations in AngularJS?

I've been trying to figure out how to animate in AngularJS by searching online, but I haven't found a perfect solution yet. html <span class="sb-arrow down" ng-click="hideSampleList($event)"></span> ...

Tips for passing data to a child component from a computed property

Currently in the process of setting up a filter using vue-multiselect. Everything seems to be working fine, but there's one issue I can't seem to resolve. Upon page reload, the label (v-model) appears empty. The root cause seems to be that the v ...

Experiencing issues with connecting to jQuery in an external JavaScript file

My jQuery formatting in the HTML file looks like this: <!doctype html> <html lang="en"> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script> </head> < ...

What could be the reason for the react hook form failing to capture the data upon submission?

I am struggling to access the props' value after clicking the button, as it keeps returning undefined. My goal is to display the years of service and profession details based on the user's selection. return ( <form onSubmit={handleSubmit(o ...

Issue with Material-UI theme after updating @material-ui/core and @material-ui/styles in React and Next.js applications

I recently updated the packages @material-ui/core*(4.4.1 => 4.8.3)* & @material/styles*(4.4.1 = 4.8.2)* Now, all elements where the theme is applied are not displaying the correct colors and margins. Could there be any significant changes in the pack ...

What is the best way to save Vue state in a cookie while transitioning between form steps in a Laravel application

Imagine a scenario where a user is filling out a multi-step form, and we want to ensure that their progress is saved in case they lose connection. This way, the user's data will not be lost between different form steps. In addition to saving each ste ...

Invoke the javascript function by referencing the JavaScript file

I'm encountering an issue with two JavaScript files. One file uses the prototype syntax, while the other utilizes jQuery. Unfortunately, they don't seem to work harmoniously together. I've attempted calling the functions within the files usi ...

Incorporating source files from an Express server into an HTML document

Recently, I delved into the world of Node.js with Express and Socket.io to create a web application, specifically a game. In my project, I have a designated /public folder where I aim to serve the necessary files for the client-side operations. Typically, ...

Enhancing parent component props in React-router-dom: A guide to updating them

Here is the structure of my App component: const App = (props) => ( <BrowserRouter> <PageTheme {...some props I'd like to change on route change}> <Switch> <Route exact path="/example"> <E ...

Using Mongoose with Next.js Middleware

Currently, I'm attempting to establish a connection between my next.js app and MongoDB using mongoose within the _middeware file located at ./pages/_middleware.ts. However, every time an incoming request is made, I encounter the following error: Erro ...

Invoke a function from a neighboring component using React hooks

Is there a way to call a function from another component using props or context? I've attempted to do this using props and context, but I'm getting confused as I need to pass an actual function with parameters. The goal is to invoke the handleS ...

The .remove() method is ineffective when used within an Ajax success function

I am facing an issue with removing HTML divs generated using jinja2 as shown below: {% for student in students %} <div class="item" id="{{ student.id }}_div"> <div class="right floated content"> <div class="negative ui button compa ...