'node_modules/@types/chrome/index.d.ts is not a module

I've nx monorepo having React TypeScript app. When I'm trying to use chrome in any of .ts file, VSCode is reporting a error saying Cannot find name 'chrome'.

I've used yarn add @types/chrome and able to see an entry in package.json as "@types/chrome": "^0.0.171", also added below configurations to ts.config.json and tsconfig.base.json

    "types": [
      "chrome","@types/chrome"
    ]

When I tried to import chrome as import chrome '@types/chrome' or import chrome 'chrome' VS Code giving error as node_modules/@types/chrome/index.d.ts' is not a module.

Any help would be very grateful.



Solution 1:[1]

I know this is a little bit old. I hope this will help someone.

If you are sure about all dependencies are installed, make a hard restart vscode.

You can use ctrl+shift+p and type reload and enter Developer:reload

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DevinRa