Yarn 2 PnP, VSCode and @types

Viewed 399

I'd like to get intellisense working for a remote library (Chart.js) without including it as a dependency (it is loaded via CDN).

So I am using @types/chart.js to allow intellisence.

  1. yarn add -D @types/chart.js
  2. add /// <reference types="chart.js" /> to my js script

It works fine with Yarn classic and npm but I cannot get it to work with Yarn 2 Pnp. Whenever I try, I get error Cannot find type definition file for 'chart.js'.ts(2688) and intellisence (obviously) stops working.

Is there any way to include @types while using Yarn 2 Pnp without using a loader?

1 Answers

Add this into your .yarnrc.yml file

nodeLinker: node-modules
Related