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?]: Not finding modules in Typescript import statements

See original GitHub issue

Self-service

  • I’d be willing to implement a fix

Describe the bug

Yarn VSCode SDK no longer working to find modules

To reproduce

  1. Create new folder
  2. yarn set version berry
  3. yarn init
  4. Create new file index.ts
  5. yarn add typescript -D
  6. write in index.ts import React from 'react'
  7. yarn add react
  8. yarn dlx @yarnpkg/sdks vscode
  9. Set Typescript version in VSCode to 4.4.2-sdk

Environment

System: OS: Windows 10 10.0.19043 CPU: (4) x64 Intel® Core™ i5-7600 CPU @ 3.50GHz Binaries: Node: 14.17.4 - C:\Users\user\AppData\Local\Temp\xfs-f520d191\node.CMD Yarn: 3.0.1 - C:\Users\user\AppData\Local\Temp\xfs-f520d191\yarn.CMD npm: 7.11.1 - C:\Program Files\nodejs\npm.CMD

Additional context

Yarn v3.0.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

17reactions
merceyzcommented, Sep 3, 2021

Set Typescript version in VSCode to 4.4.2-sdk

I missed the version number, sorry about that. TypeScript 4.4 doesn’t have the PnP patch yet, will be fixed by https://github.com/yarnpkg/berry/pull/3297, you can either run

yarn set version from sources --branch 3297 && yarn

to get the update now or downgrade to TypeScript 4.3

EDIT: Released in 3.0.2 so the command is now

yarn set version berry && yarn
4reactions
merceyzcommented, Sep 3, 2021

The fix has been released as 3.0.2 so you can now the following to fix it

yarn set version berry && yarn
Read more comments on GitHub >

github_iconTop Results From Across the Web

Common TypeScript module problems and how to solve them
Solution 2: Locate the module and resolve imports ; "*" value in the array means the exact name of the module, while the...
Read more >
Typescript - Importing a Module - Cannot Find Module
Quick solution: Use ts-node to run your TypeScript files directly npm install --dev ts-node. Start a node process with this command:
Read more >
TypeScript: Cannot use import statement outside a module
To solve the error "Cannot use import statement outside a module" in TypeScript, set the module option to commonjs in your tsconfig.json file...
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
Cannot use import statement outside a module [React ...
How to Fix the TypeScript SyntaxError: Cannot use import statement outside a module Error · Install the latest version of TypeScript, and are ......
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