2020/09/28 轮播react-slick报错 can`t resolve ‘react-slick‘

博客作者遇到在项目中安装并使用react-slick时出现问题,原先通过cnpm安装,后改为使用npm安装发现有更新。文章揭示了cnpm可能导致的依赖不一致问题,并建议开发者在安装npm包时首选官方源,以确保获取最新和最稳定的版本。同时,提供了官方文档和相关教程链接供参考。
  • 报错
    在这里插入图片描述

  • 前提

  • 我已经按照官网安装好了
    npm install react-slick --save
    npm install slick-carousel --save
    并且引入了css样式
    import “~slick-carousel/slick/slick.css”;
    import “~slick-carousel/slick/slick-theme.css”;

  • 最后发现原因
    因为我安装了淘宝镜像,安装的时候喜欢用cnpm,结果我再重新用npm安装,发现有更新,应该就是cnpm的问题
    在这里插入图片描述
    其实之前cnpm我都安装过,以后安装还是最好用npm

  • 官网链接
    https://react-slick.neostack.com/docs/get-started

  • 可以参考的链接
    https://www.cnblogs.com/huangmin1992/p/7609727.html
    https://www.npmjs.com/package/react-slick

PS D:\project\Annotation\LP_Annotation_ConfigWeb> npm install -D tailwindcss npm error code ERESOLVE npm error ERESOLVE could not resolve npm error npm error While resolving: @ant-design/v5-patch-for-react-19@1.0.3 npm error Found: react@18.3.1 npm error node_modules/react npm error peer react@">=16.0.0" from @ant-design/cssinjs@1.24.0 npm error node_modules/@ant-design/cssinjs npm error @ant-design/cssinjs@"^1.21.0" from @ant-design/cssinjs-utils@1.1.3 npm error node_modules/@ant-design/cssinjs-utils npm error @ant-design/cssinjs-utils@"^1.1.3" from antd@5.27.3 npm error node_modules/antd npm error peer antd@">=5.22.6" from @ant-design/v5-patch-for-react-19@1.0.3 npm error node_modules/@ant-design/v5-patch-for-react-19 npm error 1 more (the root project) npm error @ant-design/cssinjs@"^1.23.0" from antd@5.27.3 npm error node_modules/antd npm error peer antd@">=5.22.6" from @ant-design/v5-patch-for-react-19@1.0.3 npm error node_modules/@ant-design/v5-patch-for-react-19 npm error @ant-design/v5-patch-for-react-19@"^1.0.3" from the root project npm error 1 more (the root project) npm error peer react@">=16.9.0" from @ant-design/cssinjs-utils@1.1.3 npm error node_modules/@ant-design/cssinjs-utils npm error @ant-design/cssinjs-utils@"^1.1.3" from antd@5.27.3 npm error node_modules/antd npm error peer antd@">=5.22.6" from @ant-design/v5-patch-for-react-19@1.0.3 npm error node_modules/@ant-design/v5-patch-for-react-19 npm error @ant-design/v5-patch-for-react-19@"^1.0.3" from the root project npm error 1 more (the root project) npm error 55 more (@ant-design/icons, @ant-design/react-slick, ...) npm error npm error Could not resolve dependency: npm error peer react@">=19.0.0" from @ant-design/v5-patch-for-react-19@1.0.3 npm error node_modules/@ant-design/v5-patch-for-react-19 npm error @ant-design/v5-patch-for-react-19@"^1.0.3" from the root project npm error npm error Conflicting peer dependency: react@19.1.1 npm error node_modules/react npm error peer react@">=19.0.0" from @ant-design/v5-patch-for-react-19@1.0.3 npm error node_modules/@ant-design/v5-patch-for-react-19 npm error @ant-design/v5-patch-for-react-19@"^1.0.3" from the root project npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution. npm error npm error npm error For a full report see: npm error C:\Users\48138\AppData\Local\npm-cache\_logs\2025-09-13T03_28_42_375Z-eresolve-report.txt npm error A complete log of this run can be found in: C:\Users\48138\AppData\Local\npm-cache\_logs\2025-09-13T03_28_42_375Z-debug-0.log
09-14
请分析以下报错:npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: mobx-react@6.3.1 npm ERR! Found: react@18.3.1 npm ERR! node_modules/react npm ERR! react@"^18.2.0" from the root project npm ERR! peer react@">=16.0.0" from @ant-design/cssinjs@1.20.0 npm ERR! node_modules/@ant-design/cssinjs npm ERR! @ant-design/cssinjs@"^1.19.1" from antd@5.18.0 npm ERR! node_modules/antd npm ERR! antd@"^5.18.0" from the root project npm ERR! 2 more (antd-img-crop, fabos-commons) npm ERR! 80 more (@ant-design/icons, @ant-design/react-slick, ...) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^16.8.0 || 16.9.0-alpha.0" from mobx-react@6.3.1 npm ERR! node_modules/mobx-react npm ERR! mobx-react@"6.3.1" from the root project npm ERR! mobx-react@"^6.3.1" from amis@0.0.29 npm ERR! node_modules/amis npm ERR! amis@"^0.0.29" from the root project npm ERR! 3 more (amis-editor, amis-editor-core, amis-theme-editor-helper) npm ERR! 3 more (amis-core, amis-editor-core, amis-ui) npm ERR! npm ERR! Conflicting peer dependency: react@16.14.0 npm ERR! node_modules/react npm ERR! peer react@"^16.8.0 || 16.9.0-alpha.0" from mobx-react@6.3.1 npm ERR! node_modules/mobx-react npm ERR! mobx-react@"6.3.1" from the root project npm ERR! mobx-react@"^6.3.1" from amis@0.0.29 npm ERR! node_modules/amis npm ERR! amis@"^0.0.29" from the root project npm ERR! 3 more (amis-editor, amis-editor-core, amis-theme-editor-helper) npm ERR! 3 more (amis-core, amis-editor-core, amis-ui) npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! npm ERR! For a full report see: npm ERR! E:\install\Integrated Development Environment\node_cache\_logs\2025-03-24T06_16_27_089Z-eresolve-report.txt npm ERR! A complete log of this run can be f
03-25
{ "name": "edx", "version": "0.1.0", "repository": "https://github.com/openedx/edx-platform", "scripts": { "postinstall": "scripts/copy-node-modules.sh", "build": "npm run webpack && npm run compile-sass", "build-dev": "npm run webpack-dev && npm run compile-sass-dev", "webpack": "cross-env NODE_ENV=development webpack --config webpack.dev.config.js", "webpack-dev": "NODE_ENV=development webpack --config=webpack.dev.config.js", "compile-sass": "scripts/compile_sass.py --env=${NODE_ENV:-production}", "compile-sass-dev": "scripts/compile_sass.py --env=development", "watch": "{ npm run watch-webpack& npm run watch-sass& } && sleep infinity", "watch-webpack": "npm run webpack-dev -- --watch", "watch-sass": "scripts/watch_sass.sh", "test": "npm run test-jest && npm run test-karma", "test-jest": "jest", "test-karma": "npm run test-karma-vanilla && npm run test-karma-require && echo 'WARNING: Skipped broken webpack tests. For details, see: https://github.com/openedx/edx-platform/issues/35956'", "test-karma-vanilla": "npm run test-cms-vanilla && npm run test-xmodule-vanilla && npm run test-common-vanilla", "test-karma-require": "npm run test-cms-require && npm run test-common-require", "test-karma-webpack": "npm run test-cms-webpack && npm run test-lms-webpack && npm run test-xmodule-webpack", "test-karma-conf": "${NODE_WRAPPER:-xvfb-run --auto-servernum} node --max_old_space_size=4096 node_modules/.bin/karma start --single-run=true --capture-timeout=60000 --browsers=FirefoxNoUpdates", "test-cms": "npm run test-cms-vanilla && npm run test-cms-require && npm run test-cms-webpack", "test-cms-vanilla": "npm run test-karma-conf -- cms/static/karma_cms.conf.js", "test-cms-require": "npm run test-karma-conf -- cms/static/karma_cms_squire.conf.js", "test-cms-webpack": "npm run test-karma-conf -- cms/static/karma_cms_webpack.conf.js", "test-lms": "npm run test-jest && npm run test-lms-webpack", "test-lms-webpack": "npm run test-karma-conf -- lms/static/karma_lms.conf.js", "test-xmodule": "npm run test-xmodule-vanilla && npm run test-xmodule-webpack", "test-xmodule-vanilla": "npm run test-karma-conf -- xmodule/js/karma_xmodule.conf.js", "test-xmodule-webpack": "npm run test-karma-conf -- xmodule/js/karma_xmodule_webpack.conf.js", "test-common": "npm run test-common-vanilla && npm run test-common-require", "test-common-vanilla": "npm run test-karma-conf -- common/static/karma_common.conf.js", "test-common-require": "npm run test-karma-conf -- common/static/karma_common_requirejs.conf.js" }, "dependencies": { "@babel/core": "7.26.0", "@babel/plugin-proposal-object-rest-spread": "^7.18.9", "@babel/plugin-transform-object-assign": "^7.18.6", "@babel/preset-env": "^7.19.0", "@babel/preset-react": "7.26.3", "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2", "@edx/edx-bootstrap": "1.0.4", "@edx/edx-proctoring": "^4.18.1", "@edx/frontend-component-cookie-policy-banner": "2.2.0", "@edx/paragon": "2.6.4", "@edx/studio-frontend": "^2.1.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^12.8.3", "babel-loader": "^9.1.3", "babel-plugin-transform-class-properties": "6.24.1", "babel-polyfill": "6.26.0", "backbone": "1.6.0", "backbone-associations": "0.6.2", "backbone.paginator": "2.0.8", "bootstrap": "4.0.0", "camelize": "1.0.1", "classnames": "2.5.1", "cross-env": "^10.0.0", "css-loader": "7.1.2", "datatables": "1.10.18", "datatables.net-fixedcolumns": "5.0.4", "edx-ui-toolkit": "1.8.7", "exports-loader": "0.6.4", "file-loader": "^6.2.0", "font-awesome": "4.7.0", "hls.js": "0.14.17", "imports-loader": "0.8.0", "jest-environment-jsdom": "^29.0.0", "jquery": "2.2.4", "jquery-migrate": "1.4.1", "jquery.scrollto": "2.1.3", "js-cookie": "3.0.5", "moment": "2.30.1", "moment-timezone": "0.5.47", "node-gyp": "11.1.0", "popper.js": "1.16.1", "prop-types": "15.8.1", "raw-loader": "0.5.1", "react": "16.14.0", "react-dom": "16.14.0", "react-focus-lock": "^1.19.1", "react-redux": "5.1.2", "react-router-dom": "5.3.4", "react-slick": "0.30.3", "redux": "3.7.2", "redux-thunk": "2.2.0", "requirejs": "2.3.7", "rtlcss": "4.3.0", "sass": "^1.54.8", "sass-loader": "^16.0.0", "scriptjs": "2.5.9", "style-loader": "4.0.0", "svg-inline-loader": "0.8.2", "uglify-js": "3.19.3", "underscore": "1.13.7", "underscore.string": "3.3.6", "webpack": "^5.90.3", "webpack-bundle-tracker": "3.2.0", "webpack-merge": "6.0.1", "which-country": "1.0.0" }, "devDependencies": { "@edx/mockprock": "1.0.2", "@edx/stylelint-config-edx": "2.3.3", "babel-jest": "29.7.0", "jasmine-core": "2.6.4", "jasmine-jquery": "2.1.1", "jest": "29.7.0", "karma": "0.13.22", "karma-chrome-launcher": "3.2.0", "karma-coverage": "2.2.1", "karma-firefox-launcher": "2.1.3", "karma-jasmine": "0.3.8", "karma-jasmine-html-reporter": "0.2.2", "karma-junit-reporter": "2.0.1", "karma-requirejs": "1.1.0", "karma-selenium-webdriver-launcher": "latest", "karma-sourcemap-loader": "0.4.0", "karma-spec-reporter": "0.0.20", "karma-webpack": "^5.0.1", "plato": "1.7.0", "react-test-renderer": "16.14.0", "selenium-webdriver": "^2.44.0", "sinon": "19.0.2", "squirejs": "0.1.0", "string-replace-loader": "^3.1.0", "stylelint-formatter-pretty": "4.0.1", "webpack-cli": "^5.1.4" } }
最新发布
09-25
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值