![](/img/trans.png)
[英]Bootstrap react ./node_modules/bootstrap/dist/js/bootstrap.min.js Module not found: Can't resolve 'jquery'
[英]Module not found: Can't resolve 'moment' in 'node_modules\react-moment\dist' in reactjs
我已经安装了 react-moment 'npm i react-moment'。 安装在node_modules目录下,依赖添加在package.json文件中。 每件事都是正确的。 但是当我导入
import Moment from 'react-moment'
然后它显示
Module not found: Can't resolve 'moment' in 'node_modules\react-moment\dist'
但是这个目录没有任何问题,我没有修改node_modules中react-moment目录里面的文件。 在安装 package 之后,当我导入 package 时
import Moment from 'react-moment'
然后它显示错误。
moment
是react-moment
的对等依赖项,这意味着您还必须在项目中安装moment
(它不附带自己的moment
版本)。
npm i --save moment
我通过在命令末尾添加“--legacy-peer-deps”参数来解决这个问题,如错误消息所示:
npm ERR: Conflicting peer dependency. @angular/common@13.3.12 npm ERR. node_modules/@angular/common npm ERR. peer @angular/common@">=13.0.0 <14.0.0" from @ng-select/ng-select@8.3.0 npm ERR. node_modules/@ng-select/ng-select npm ERR. @ng-select/ng-select@"^8.0.0" from @ng-matero/extensions@13.1,0 npm ERR, node_modules/@ng-matero/extensions npm ERR. @ng-matero/extensions@"^13.1.0" from the root project npm ERR. @ng-select/ng-select@"^8:1.1" from the root project 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! See /Users/yimin/.npm/eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR! /Users/yimin/.npm/_logs/2022-12-01T14_08_17_585Z-debug-0.log
npm install --save moment --legacy-peer-deps
为我工作:
npm install --save moment
npm install --save react-moment
npm install --save moment-timezone
:)
我在使用 reac -datetime package 时遇到了同样的问题,这个问题对我有用:
npm install --save moment
如果您正在使用时区功能,请确保您也安装了时区 package。 如果不粘贴下面的 npm 代码。
npm install --save moment-timezone
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.