Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Not finding modules in Typescript import statements #3350

Closed
1 task
imdavidmin opened this issue Aug 26, 2021 · 16 comments · Fixed by #3297
Closed
1 task

[Bug?]: Not finding modules in Typescript import statements #3350

imdavidmin opened this issue Aug 26, 2021 · 16 comments · Fixed by #3297
Labels
bug Something isn't working upholded Real issues without formal reproduction

Comments

@imdavidmin
Copy link

imdavidmin commented Aug 26, 2021

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(R) Core(TM) 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

@imdavidmin imdavidmin added the bug Something isn't working label Aug 26, 2021
@merceyz
Copy link
Member

merceyz commented Aug 26, 2021

You're missing a dependency on @types/react

@imdavidmin
Copy link
Author

imdavidmin commented Aug 26, 2021

@merceyz Unfortunately that does not solve the issue. Ran yarn add -D @types/react. No difference.

This is not a React specific issue. All modules are not found unless they are relative paths.

@merceyz
Copy link
Member

merceyz commented Aug 26, 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 #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

@merceyz merceyz added the upholded Real issues without formal reproduction label Aug 26, 2021
@imdavidmin
Copy link
Author

Thank you @merceyz! Been scratching my head for a while

@merceyz
Copy link
Member

merceyz commented Aug 26, 2021

I'll reopen to increase visibility for others running into the same issue

@merceyz merceyz reopened this Aug 26, 2021
@imdavidmin
Copy link
Author

In that case, is there a way to run yarn dlx @yarnpkg/sdks vscode to get the 4.3.* version of Typescript? I'm able to use old files in other projects.

@merceyz
Copy link
Member

merceyz commented Aug 26, 2021

The SDK is unrelated here so yarn up typescript@~4.3 would change all your direct typescript dependencies to ~4.3

@TimVosch
Copy link

Been stuck on this for a while. Luckily I searched the issues and removed the "is:open" filter :)

@merceyz
Copy link
Member

merceyz commented 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

@lamhungypl
Copy link

lamhungypl commented Nov 24, 2021

Unfortunately, this issue still occurs.
I started a new yarn create vite my-app --template react-ts project, nothing work except yarn dev
(same issue with yarn create react-app my-app)

System:
OS: macOS 12.0.1
CPU: 2 GHz Quad-Core Intel Core i5
Node: 16.13.0
Yarn: 3.1.0

package.json
{
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "serve": "vite preview",
    "prepare": "husky install"
  },
  "dependencies": {
    "antd": "^4.17.1",
    "react": "^17.0.0",
    "react-dom": "^17.0.0"
  },
  "devDependencies": {
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@vitejs/plugin-react": "^1.0.0",
    "eslint": "^8.2.0",
    "husky": "^7.0.4",
    "prettier": "^2.4.1",
    "typescript": "^4.3.2",
    "vite": "^2.6.4"
  },
  "lint-staged": {
    "*.js": "eslint --cache --fix",
    "*.{js,css,md}": "prettier --write"
  }
}

Screen Shot 2021-11-24 at 15 59 48

@merceyz
Copy link
Member

merceyz commented Nov 24, 2021

@lamhungypl See #3722 (comment)

@MAST1999
Copy link

@lamhungypl See #3722 (comment)

Hey, I had the same problem but after using yarn set version berry && yarn I can build and run the project from the terminal but vscode keeps complaining that the modules or their types don't exist.
image
I was wondering if I had missed something.
I also ran yarn dlx @yarnpkg/sdks vscode

Thanks for the hard work.

@shonsirsha
Copy link

@lamhungypl See #3722 (comment)

Hey, I had the same problem but after using yarn set version berry && yarn I can build and run the project from the terminal but vscode keeps complaining that the modules or their types don't exist. image I was wondering if I had missed something. I also ran yarn dlx @yarnpkg/sdks vscode

Thanks for the hard work.

Hi, did you find any solution for this?

@MAST1999
Copy link

MAST1999 commented Feb 7, 2022

@lamhungypl See #3722 (comment)

Hey, I had the same problem but after using yarn set version berry && yarn I can build and run the project from the terminal but vscode keeps complaining that the modules or their types don't exist. image I was wondering if I had missed something. I also ran yarn dlx @yarnpkg/sdks vscode

Thanks for the hard work.

Hi, did you find any solution for this?

Nope, unfortunately.
I ended up going back to yarn version 1.

@koistya
Copy link
Contributor

koistya commented Feb 7, 2022

@MAST1999 it should work with Yarn v2 and PnP. Are you sure you have @types/react and @types/react-dome dependencies installed?

Eaxmple: GraphQL API and Relay Starter Kitweb/package.json#L53-L54

@MAST1999
Copy link

MAST1999 commented Feb 7, 2022

@koistya
Yeah I was sure. I even saw the packages in the cache and I had installed the needed extension mentioned in the docs.
But I still couldn't get vscode to recognize them.
I was on the version 3 BTW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upholded Real issues without formal reproduction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants