关于 reactjs:找不到模块”react-hover”的声明文件 | 珊瑚贝

Could not find a declaration file for module ‘react-hover’


我从 https://github.com/cht8687/react-hover

为我的反应代码安装了 \\’react-hover\\’ 库

我使用了如下的导入语句:import ReactHover from ‘react-hover’;

然后我得到这个错误

找不到模块 \\’react-hover\\’ 的声明文件。 \\’d:/…….(path)/index.js\\’ 隐式具有 \\’any\\’ 类型。
如果 npm install @types/react-hover 存在,请尝试或添加包含 declare module ‘react-hover’;ts(7016)

的新声明 (.d.ts) 文件

当我尝试npm install @types/react-hover时,
它也不起作用(导致以下错误)

npm 错误! 404 \\’@types/react-hover@latest\\’ 不在 npm 注册表中。

npm 错误! 404 你的包名无效,因为

npm 错误! 404 1.名称只能包含URL友好字符

我该如何解决这个问题?


这意味着当前没有可用于该依赖项的类型定义,因为包所有者/社区尚未创建它们。

一个快速的解决方法是在您的项目中创建一个包含 declare module ‘react-hover’; 的新声明文件 (declarations.d.ts),就像错误状态一样:

Try npm install @types/react-hover if it exists or add a new
declaration (.d.ts) file containing declare module ‘react-hover’;

请注意,不会为您的项目添加此依赖项的类型检查!


你试过 import * as ReactHover from”react-hover” 吗?这有时是由于在某些库中使用了typescript。

  • 当我按照你说的那样尝试时也存在同样的问题。我认为@Potato 说了问题的原因


来源:https://www.codenong.com/54998669/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8865.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?