【问题标题】:Yarn 2 PnP, VSCode and @typesYarn 2 PnP、VSCode 和 @types
【发布时间】:2021-04-12 10:33:32
【问题描述】:

我想让 intellisense 为远程库 (Chart.js) 工作,而不将其作为依赖项包含(通过 CDN 加载)。

所以我使用@types/chart.js 来实现智能。

  1. yarn add -D @types/chart.js
  2. 在我的 js 脚本中添加/// <reference types="chart.js" />

它适用于 Yarn classic 和 npm,但我无法让它适用于 Yarn 2 Pnp。每当我尝试时,我都会收到错误 Cannot find type definition file for 'chart.js'.ts(2688) 并且智能(显然)停止工作。

在不使用加载器的情况下使用 Yarn 2 Pnp 时,有什么方法可以包含 @types

【问题讨论】:

    标签: typescript visual-studio-code typescript-typings yarnpkg


    【解决方案1】:

    将此添加到您的 .yarnrc.yml 文件中

    nodeLinker: node-modules
    

    【讨论】:

      猜你喜欢
      • 2020-05-17
      • 2022-01-02
      • 2021-03-27
      • 2021-12-04
      • 2020-06-25
      • 2021-02-15
      • 2021-01-04
      • 2019-07-24
      • 2021-10-30
      相关资源
      最近更新 更多