Skip to content

Typescript and pnp enabled app fails to compile #7456

New issue

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

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

Already on GitHub? # to your account

Closed
mateja176 opened this issue Jul 31, 2019 · 15 comments
Closed

Typescript and pnp enabled app fails to compile #7456

mateja176 opened this issue Jul 31, 2019 · 15 comments

Comments

@mateja176
Copy link

Describe the bug

yarn start results in the following error

Failed to compile.

undefined
TypeScript error in undefined(undefined,undefined):
Cannot find type definition file for 'lodash'.  TS2688

Did you try recovering your dependencies?

Ran yarn, using yarn@latest ( atm yarn@1.17.3 )

Which terms did you search for in User Guide?

  • typescript
  • yarn pnp
  • typescript and yarn pnp
  • lodash

Environment

Environment Info:

  System:
    OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
    CPU: (8) x64 AMD Ryzen 7 2700U with Radeon Vega Mobile Gfx
  Binaries:
    Node: 11.14.0 - ~/.nvm/versions/node/v11.14.0/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v11.14.0/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v11.14.0/bin/npm
  Browsers:
    Chrome: 75.0.3770.142
    Firefox: 68.0.1
  npmPackages:
    react: Not Found
    react-dom: Not Found
    react-scripts: Not Found
  npmGlobalPackages:
    create-react-app: 3.0.1

Steps to reproduce

(Write your steps here:)

  1. create-react-app test --typescript --use-pnp
  2. cd test
  3. yarn
  4. yarn start

Expected behavior

No error occurs and app start sucessfully

Actual behavior

yarn-pnp-terminal

yarn-pnp-browser

Reproducible demo

https://github.com/mateja176/yarn-pnp-demo

@mateja176
Copy link
Author

Related #5647

@mrmckeb
Copy link
Contributor

mrmckeb commented Oct 19, 2019

I hit this recently too, and couldn't find a fix. @iansu perhaps we should ask the Yarn team for thoughts on this?

@mrmckeb mrmckeb added this to the 3.3 milestone Oct 19, 2019
@iansu
Copy link
Contributor

iansu commented Oct 19, 2019

We can try but I think they're pretty focused on shipping Yarn 2 at the moment. cc @arcanis

@arcanis
Copy link
Contributor

arcanis commented Oct 19, 2019

Fwiw I'd recommend using the v2 for any project using PnP.

Afaik a single blocker remains, which is the following error. We've recently fixed it in typescript-eslint master (typescript-eslint/typescript-eslint#990), which should hopefully be released in the next few days.

Failed to load plugin '@typescript-eslint' declared in 'BaseConfig » /home/arcanis/cra-test/.yarn/virtual/eslint-config-react-app-virtual-fa3c1f4ab2/0/cache/eslint-config-react-app-npm-5.0.2-b7b16e6537-1.zip/node_modules/eslint-config-react-app/index.js#overrides[0]': A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't

Required package: typescript (via "typescript")
Required by: tsutils@virtual:db6b93c726ffe978bd77e193f18a927c151ea6cc1f8f135748afebc0f8711d2c012ede19de70d3728ab968fc466d9b07698ccfcc97c03d093191cd80d35ad23f#npm:3.17.1 (via /home/arcanis/cra-test/.yarn/virtual/tsutils-virtual-4a3a585d45/0/cache/tsutils-npm-3.17.1-ed6df1e57e-1.zip/node_modules/tsutils/typeguard/2.8/node.js)

For now you can experiment by cloning typescript-eslint and yarn linking it to your project. Doing this seems to work fine for me 🙂

@iansu
Copy link
Contributor

iansu commented Oct 19, 2019

@arcanis thanks for the suggestion. It sounds like Yarn v2 is getting close to release? I personally can't wait for it! 🙌

@ianschmitz ianschmitz modified the milestones: 3.3, 3.4 Dec 5, 2019
@SEAPUNK
Copy link

SEAPUNK commented Jan 10, 2020

This issue is reproducible with Yarn v2, fwiw:

Failed to compile.

undefined
TypeScript error in undefined(undefined,undefined):
Cannot find type definition file for 'babel__traverse'.  TS2688

@arcanis
Copy link
Contributor

arcanis commented Jan 10, 2020

@SEAPUNK Can you send a PR to Yarn's E2E test? Afaik CRA, TS, and Yarn 2 work fine:
https://github.com/yarnpkg/berry/blob/master/.github/workflows/e2e-cra-workflow.yml

@SEAPUNK
Copy link

SEAPUNK commented Jan 10, 2020

@arcanis Sure, I'll try to get a minimal repro first.

@SEAPUNK
Copy link

SEAPUNK commented Jan 10, 2020

Never mind, it's not happening because of our CRA TS setup, it's happening because it's in our monorepo, I assume there are files in the directory above that are messing with how it starts up.

@timini
Copy link

timini commented Jan 14, 2020

Im also having this issue trying to use CRA as a monorepo package (yarn workspaces) with yarn PNP

@timini
Copy link

timini commented Jan 14, 2020

any clues not to solve? seems nohoist is not an option for PNP

@chrislambe
Copy link

Also running into this in a monorepo with CRA.

@iansu iansu modified the milestones: 3.4, 3.5 Feb 14, 2020
@Felix-Indoing
Copy link

Same problem here with CRA 3.4.1 & typescript 3.8.3 & yarn 2 monorepo:

Failed to compile.

undefined
TypeScript error in undefined(undefined,undefined):
Cannot find type definition file for 'accepts'.  TS2688

@merceyz
Copy link
Contributor

merceyz commented Oct 24, 2020

This has been fixed already, it was an issue in ts-pnp fixed in arcanis/ts-pnp@66433e6 which was updated in #8947

@iansu
Copy link
Contributor

iansu commented May 19, 2021

Closing as this seems to be fixed.

@iansu iansu closed this as completed May 19, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

10 participants