【问题标题】:'dayjs' should be listed in the project's dependencies lint error'dayjs' 应该列在项目的依赖项 lint 错误中
【发布时间】:2021-03-29 05:50:11
【问题描述】:

我在我的项目中添加了 day.js(因为 moment.js 已被弃用),运行 lint 后,我​​收到了这个错误:

'dayjs' should be listed in the project's dependencies. Run 'npm i -S dayjs' to add it

我不使用 npm,而是使用 yarn。试图用谷歌搜索它,但没有运气。有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: reactjs react-native eslint lint


    【解决方案1】:

    尝试在你的 eslintrc.js 中添加这段代码

     settings: {
     'import/core-modules': ['dayjs'],
     }
    

    【讨论】:

      【解决方案2】:

      因为接受的答案是一种方法,即

      settings: {
       'import/core-modules': ['dayjs'],
      }
      

      或者dayjs可以在package.json中安装为devDependencies,安装为dependencies也可以解决。

      【讨论】:

      • 你是怎么做到的?
      • 我不确定你使用的是什么包管理器npmyarn,但首先你必须从devDependencies 卸载dayjs。或者它可能安装为peerDependency。然后只需执行 npm install dayjsyarn add dayjs 即可将其安装在 package.json 的 dependencies
      猜你喜欢
      • 1970-01-01
      • 2021-08-07
      • 2017-12-09
      • 1970-01-01
      • 2018-10-29
      • 2018-07-20
      • 2017-09-11
      • 2017-03-28
      • 2012-09-17
      相关资源
      最近更新 更多