[英]node_modules/@types/chrome/index.d.ts is not a module
I've nx monorepo having React TypeScript app.我有 nx monorepo 有 React TypeScript 应用程序。 When I'm trying to use
chrome
in any of .ts
file, VSCode is reporting a error saying Cannot find name 'chrome'.
当我尝试在任何
.ts
文件中使用chrome
时,VSCode 报告错误,提示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
我使用
yarn add @types/chrome
并能够在package.json
中看到一个条目为"@types/chrome": "^0.0.171",
还将以下配置添加到ts.config.json
和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.
当我尝试将
chrome
导入为import chrome '@types/chrome'
或import chrome 'chrome'
VS Code 时出现错误,因为node_modules/@types/chrome/index.d.ts' is not a module.
Any help would be very grateful.任何帮助将不胜感激。
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.如果您确定所有依赖项都已安装,请硬重启 vscode。
You can use
ctrl+shift+p
and typereload
and enterDeveloper:reload
您可以使用
ctrl+shift+p
并键入reload
并输入Developer:reload
Using just import 'chrome';
只使用
import 'chrome';
instead of import { chrome } from 'chrome';
而不是
import { chrome } from 'chrome';
worked for me为我工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.