Cannot find modules or corresponding type declarations after fresh install

If anyone encountered this problem while setting up their local dev environment, this is how I solved it.

The issue is to related how to VSCode is configured to run yarn v2+ plug-and-play TypeScript. When doing a vanilla install, you will notice that these imports will fail even though Grafana starts up normally - this is because Grafana is configured to work with yarn IDE SDKs. So VSCode needs to be configured to support them, if it isn’t already.

  1. Note in the Grafana repo, the package manager is declared in package.json. This is the version you should have on your machine

    “packageManager”: “yarn@3.1.0”

  2. Install and set latest yarn version

    yarn set version latest

  3. Install yarn’s IDE SDK for VSCode (the dlx command runs yarn in a separate environment, distinct from the workspace)

    yarn dlx @yarnpkg/sdks vscode

  4. Restart VSCode
1 Like