question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Pnpify does not resolve tsconfig's paths in VSCode

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

  • I have a Typescript monorepo with nx and yarn PnP
  • VSCode is configured according to the documentation using yarn dlx @yarnpkg/pnpify --sdk vscode and changing the workspace version to 4.2.4-pnpify

Expected VSCode is able to resolve the typings of external dependencies (e.g. rxjs) and local dependencies (e.g. Nx library, using the tsconfig.json’s paths configuration).

Actual

  • VSCode is able to resolve the typings of external dependencies
  • VSCode is not able to resolve local dependencies and throws the error Cannot find module '@issue-yarn-pnp-vscode-nx/foo' or its corresponding type declarations.ts(2307) (see screenshot)

Notes

  • However, changing VSCode’s TS version to the default one results in VSCode not able to resolve external dependencies but able to resolve local dependencies
  • the problem is only in VSCode because running yarn nx build bar --with-deps works and typescript is able to resolve the dependencies
Screenshot 2021-07-13 at 21 30 54

To reproduce

Here is a very simple repo that reproduces the issue https://github.com/micaelmbagira/issue-yarn-pnp-vscode-nx

Environment

  System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
  Binaries:
    Node: 14.16.0 - /private/var/folders/07/fjm413m14h1dwkpqyd0tps5h0000gn/T/xfs-d934ada9/node
    Yarn: 2.4.2 - /private/var/folders/07/fjm413m14h1dwkpqyd0tps5h0000gn/T/xfs-d934ada9/yarn
    npm: 7.11.2 - ~/.config/yarn/global/node_modules/.bin/npm

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
micaelmbagiracommented, Aug 31, 2021

@merceyz I confirm that it works now, thanks, this one will unblock all the Nx users!!

0reactions
micaelmbagiracommented, Oct 15, 2021

@merceyz when do you plan to release this bugfix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code can't resolve angular's tsconfig paths
VsCode automatically looks for a tsconfig.json file and it doesn't care about tsconfig.app.json , so paths needs to be specified in tsconfig.
Read more >
TypeScript Programming with Visual Studio Code
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It offers classes, modules, and interfaces to help you build robust...
Read more >
Tasks in Visual Studio Code
Integrate with External Tools via Tasks. Lots of tools exist to automate tasks like linting, building, packaging, testing, or deploying software systems.
Read more >
Visual Studio Code February 0.10.11
To enable JavaScript inside a TypeScript project, you can set the allowJs property to true in the tsconfig.json . Tip: The tsc compiler...
Read more >
TypeScript tutorial with Visual Studio Code
You've likely not set "sourceMap": true in your tsconfig.json and the VS Code Node.js debugger can't map your TypeScript source code to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found