1

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.

Ravi MCA
  • 2,491
  • 4
  • 20
  • 30
  • Does this answer your question? [Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type](https://stackoverflow.com/questions/41292559/could-not-find-a-declaration-file-for-module-module-name-path-to-module-nam) – Mohammad Hossein Dolatabadi Dec 31 '21 at 07:37
  • @MohammadHosseinDolatabadi Tried the answers, but it didn't help – Ravi MCA Jan 03 '22 at 09:42

2 Answers2

2

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

DevinRa
  • 115
  • 1
  • 7
0

Using just import 'chrome'; instead of import { chrome } from 'chrome'; worked for me