我已经安装了 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 目录下的文件。安装包后,当我导入包时import Moment from 'react-moment'
然后它显示错误。
最佳答案
moment
是 peer dependency的 react-moment
,这意味着您必须安装 moment
在您的项目中也是如此(它不附带自己的 moment
版本)。npm i --save moment
关于javascript - 找不到模块 : Can't resolve 'moment' in 'node_modules\react-moment\dist' in reactjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63137095/