reactjs 无法找到模块“Cannot find”

idv4meu8  于 2023-05-28  发布在  React
关注(0)|答案(6)|浏览(138)

我正在尝试在我的React项目中使用react-slick。当我试图导入它时

import Slider from 'react-slick';

我得到这个错误

Cannot find module "react-slick"

其他人有这个问题吗?
https://github.com/akiran/react-slick安装

npm install react-slick

还安装slick-carousel的css和字体

npm install slick-carousel

React V“react@^15.4.1”
NPM安装结果

npm install react-slick --save
(node:14297) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
fb-lite@1.1.0 ..blal
└─┬ react-slick@0.14.5 
  ├─┬ json2mq@0.2.0 
  │ └── string-convert@0.2.1 
  ├─┬ react-responsive-mixin@0.4.0 
  │ ├── can-use-dom@0.1.0 
  │ └── enquire.js@2.1.1 
  └─┬ slick-carousel@1.6.0 
    └── jquery@3.1.1 

npm install slick-carousel --save
(node:14298) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
fb-lite@1.1.0 ..blal
└── slick-carousel@1.6.0
jm2pwxwz

jm2pwxwz1#

在react组件文件中:从'react-slick'导入滑块;
在package.json中检查版本:“react-slick”:“^0.15.4”
这对我很有效。

qc6wkl3g

qc6wkl3g2#

**我遇到过同样的问题,**请运行以下命令:-

yarn remove react-slick // If you installed through yarn

 or

npm uninstall react-slick // If you installed through npm

then run:-

npm install react-slick --save
9rygscc1

9rygscc13#

这对我很有效

rm -rf node_modules

delete package-lock.json

npm i
yeotifhr

yeotifhr4#

对我来说工作当我改变从这个

import Slider from“react-slick”;

到这个

import Slider from 'react-slick';

tcbh2hod

tcbh2hod5#

这对我来说很好

npm uninstall react-slick --legacy-peer-deps
rwqw0loc

rwqw0loc6#

卸载并重新安装react-slick。如果这不起作用,那么检查package.json文件中的模块:

"dependencies": {
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"react-slick": "^0.28.1",
"react-twitter-embed": "^3.0.3",
"reactjs-popup": "^2.0.5",
"slick-carousel": "^1.8.1"   }

相关问题