简体   繁体   English

node_modules/@types/chrome/index.d.ts 不是模块

[英]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.jsontsconfig.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 type reload and enter Developer: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.

相关问题 SPFx Webpart - node_modules/@types/ [prop types] 和 [react] index.d.ts:gulp 构建时加载“错误 TS1005” - SPFx Webpart - node_modules/@types/ [prop types] and [react] index.d.ts: loads of "error TS1005" on gulp build 错误:TypeScript /home/runner/work/avi/avi/node_modules/@types/react-router/index.d.ts(149,100) 中的错误:预期类型。 TS1110 - Error: TypeScript error in /home/runner/work/avi/avi/node_modules/@types/react-router/index.d.ts(149,100): Type expected. TS1110 目录/node_modules/@antv/g6-core/lib/types/index.d.ts(24,37) 中的 TypeScript 错误:预期类型。 TS1110 - TypeScript error in directory/node_modules/@antv/g6-core/lib/types/index.d.ts(24,37): Type expected. TS1110 运行测试时出现问题 @types/testing-library__react/node_modules/pretty-format/build/index.d.ts (7, 13): '=' 预期 - issue while running test @types/testing-library__react/node_modules/pretty-format/build/index.d.ts (7, 13): '=' expected /home/Documents/node_modules/cheerio-select/lib/index.d.ts(1,15) 中的 TypeScript 错误:预期为 [0] ','。 TS1005 - TypeScript error in /home/Documents/node_modules/cheerio-select/lib/index.d.ts(1,15): [0] ',' expected. TS1005 在执行“npx sb init”(反应故事书)之后:node_modules/react-router/index.d.ts:151:74 - 错误 TS1110:类型预期错误 - after doing "npx sb init" (react storybook): node_modules/react-router/index.d.ts:151:74 - error TS1110: Type expected error 由于react / types / index.d.ts而导致VS2017构建失败 - VS2017 Build failing because of react/types/index.d.ts 组件无法从 React Native 中的 index.d.ts 文件自动导入类型 - Component fails to auto import types from index.d.ts file in React Native 模块构建失败(来自./node_modules/ts-loader/index.js):错误:TypeScript 没有发出 output - Module build failed (from ./node_modules/ts-loader/index.js): Error: TypeScript emitted no output for node_modules/@types/react/index"' 没有默认导出 - node_modules/@types/react/index"' has no default export
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM