首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法找到模块的声明文件“react declaration / for”

无法找到模块的声明文件“react declaration / for”
EN

Stack Overflow用户
提问于 2021-06-18 14:43:37
回答 2查看 2K关注 0票数 3

我想在我的react项目中使用react显示包。是我安装的。但是react找不到模块

Could not find a declaration file for module 'react-reveal/Fade'.

但是,在package.json文件和节点模块中显示的是react显示。

代码语言:javascript
复制
"dependencies": {
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "bootstrap": "^4.6.0",
    "jquery": "^3.6.0",
    "react": "^17.0.2",
    "react-bootstrap": "^1.6.1",
    "react-dom": "^17.0.2",
    "react-parallax": "^3.3.0",
    "react-reveal": "^1.2.2",
    "react-router-bootstrap": "^0.25.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "react-scroll": "^1.8.2",
    "react-water-wave": "^1.0.5",
    "web-vitals": "^1.1.2"
  },

我试着安装npm i --save-dev @types/react-reveal

然后这个错误就来了

'@types/react-reveal@latest' is not in the npm registry.

我怎么才能解决这个问题?

注:我没有使用打字稿

EN

回答 2

Stack Overflow用户

发布于 2021-10-18 03:05:43

使用require导入包

代码语言:javascript
复制
import "./Product.scss"
//use require to import the module
const Fade = require("react-reveal/Fade")

export interface IProduct {
    price: number
    title: string
    img: string
}
const Product: React.FC<IProduct> = ({ price, title, img }) => {
    return (
        <Fade bottom cascade>
            <li className="product-wrapper">
                <div className="product-container">
                    <img src={`${img}`} alt="" />
                    <div className="main-details">
                        <div className="title">{title}</div>
                        <div className="details">
                            <div className="price">Price: $ {price}</div>
                            <div className="button-wrapper">
                                <button className="button btn-primary">
                                    Add to cart
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </li>
        </Fade>
    )
}

export default Product

尝试了这个实现,它成功了。

票数 2
EN

Stack Overflow用户

发布于 2021-10-18 03:13:19

运行以下命令without typescript

nom install react-reveal

npm install react-reveal/Fade --save

代码语言:javascript
复制
import { Fade } from 'react-reveal';
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68037185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档