VScode intellisense very slow when 'node_modules' is present
Asked Answered
D

5

6

VScode intelliSense is way too slow when working with a certain TypeScript, NextJs project. The problem seemed to be the node_modules folder, when i delete node_modules the intelliSense seem to be working very fast. I've tried many solutions from StackOverflow nothing seems to work.

I tried :

  • Disabling all the extensions
  • Switched to VScode insiders version.
  • Change target attribute to es6 in tsconfig.json

but the problem still persist.

My tsconfig.json looks like this :

{
    "compilerOptions": {
        "target": "es5",
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "noEmit": true,
        "esModuleInterop": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "baseUrl": "./",
        "paths": {
            "@components/*": ["./components/*"],
            "@containers/*": ["./containers/*"],
            "@assets/*": ["./assets/*"],
            "@icons/*": ["./assets/Icons/*"],
            "@logo": ["./assets/Logo/MemeChat"],
            "@styles/*": ["./styles/*"],
            "@ui/*": ["./components/UI/*"],
            "@aws/*": ["./aws/*"],
            "@store/*": ["./store/*"],
            "@hooks/*": ["./hooks/*"],
            "@reducer/*": ["./reducer/*"],
            "@types": ["./types/types.ts"],
            "@constants": ["./constants/CONSTANTS.ts"]
        },
        "incremental": true
    },
    "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
    "exclude": ["node_modules", ".next", "node_modules/**", "node_modules/*"]
}

My package.json looks like this :

{
    "name": "meme-chat",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint",
        "host": "next dev -H 192.168.1.7"
    },
    "dependencies": {
        "amazon-cognito-identity-js": "^5.1.0",
        "next": "^12.1.6",
        "react": "^18.2.0",
        "react-dom": "^18.2.0",
        "styled-components": "^5.3.5"
    },
    "devDependencies": {
        "@types/node": "^18.0.0",
        "@types/react": "^17.0.33",
        "@types/react-dom": "^17.0.10",
        "@types/styled-components": "^5.1.15",
        "eslint": "7.32.0",
        "eslint-config-next": "11.1.0",
        "typescript": "^4.4.4"
    }
}
Disposed answered 31/8, 2022 at 16:26 Comment(0)
C
2

It turned out it was a particular VS Code extension for me. Angular Language Service. Disabling this made it lightning quick.

Try this to see if it is a particular extension.

Open Command Palette (Ctrl+Shift+P) Type in "Disable all installed extensions" Enable them one by one or in groups and test the intellisense speed

Castalia answered 31/8, 2022 at 16:27 Comment(1)
I already tried disabling all the extensions, I even tried in VScode insiders with no extensions installed. When I delete 'node_modules' the intellisense seemed to be working fine.Disposed
I
2

Add node_modules to .gitignore file

We are not supposed to keep track of node_modules in git, and scanning all the files in it slows things down.

Intaglio answered 17/10, 2022 at 20:53 Comment(0)
D
2

I've been facing the same problem and found a solution that worked in my project. I recently noticed an interesting way to find the dependency that causes the problem.

Follow these steps:

  1. First you need to comment on all the imports in one file for testing reasons.
  2. Then reload VSCode using ctrl + shift + p: Developer: Reload Window
  3. Now place yourself on some statement in your code and you will notice that Intellisense is working.
  4. Start uncommenting line by line all your imports and check the Intellisense status box each time you uncommented an import. You'll notice which dependency was causing the issue performance.

In my case was the type UseControllerProps from react-hook-form.

In some cases, other components in your file might cause this issue's performance, you'll notice when the import of a component is the problem, then you will need to test the component's file to find the issue.

POV: This issue seems to be present when you use typescript.

Delineator answered 5/8, 2023 at 15:25 Comment(0)
F
0

In my case the problem was something completely different: it turned out to be Crowstrike Falcon, the security platform. Removed it and all was again back to blazing speed! Even ngx-translate intellisense started working again. So you also might want to check those kind of services that sit in your services.......

Falsity answered 27/6, 2023 at 20:44 Comment(0)
Y
0

You can try to change the version of Typescript to the one in your node_modules

enter image description here

Yep answered 4/6 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.