create-react-app: yarn pnp doesn't work with typescript
Set up a pnp typescript project
npx create-react-app pnp --use-pnp --typescript
or npx create-react-app pnp --typescript --use-pnp
order doesnβt matter
You then get
yarn add v1.12.1
[1/5] π Resolving packages...
[2/5] π Fetching packages...
[3/5] π Linking dependencies...
[5/5] π Building fresh packages...
success Saved lockfile.
success Saved 8 new dependencies.
info Direct dependencies
ββ @types/jest@23.3.9
ββ @types/node@10.12.1
ββ @types/react-dom@16.0.9
ββ @types/react@16.4.18
ββ react-dom@16.6.0
ββ react-scripts@2.1.0
ββ react@16.6.0
ββ typescript@3.1.4
info All dependencies
ββ @types/jest@23.3.9
ββ @types/node@10.12.1
ββ @types/react-dom@16.0.9
ββ @types/react@16.4.18
ββ react-dom@16.6.0
ββ react-scripts@2.1.0
ββ react@16.6.0
ββ typescript@3.1.4
β¨ Done in 14.72s.
We detected TypeScript in your project (src/App.test.tsx) and created a tsconfig.json file for you.
It looks like you're trying to use TypeScript but do not have typescript installed.
Please install typescript by running yarn add typescript.
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files).
Aborting installation.
node --require /Users/bond/Projects/pnp-test/.pnp.js has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.
Environment
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Binaries:
Node: 8.12.0 - /usr/local/bin/node
Yarn: 1.12.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
npmGlobalPackages:
create-react-app: Not Found
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 41
- Comments: 17 (5 by maintainers)
Commits related to this issue
- add typescript https://github.com/facebook/create-react-app/issues/5647 — committed to hygraph/react-scripts by hmeissner 6 years ago
I found the time and pushed a PR: https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/250
Once merged Iβll make another one to create-react-app to upgrade fork-ts-checker-webpack-plugin and add support for the resolvers π
PR up at #6856
This works but is needlessly complicated:
@alaatm Iβve got similar error when I run
yarn create react-app another-app --typescript --use-pnp
. Iβve runyarn create react-app another-app --typescript
instead and thenyarn --pnp
. Then Iβve got exactly the same error so I runyarn install
. Did not helped so I run it again as I was expecting to seesuccess Already up-to-date
but it seems that withpnp
it always go through all the steps. This madeyarn run start
run. There were any changes toyarn.lock
nor.pnp.js
files. Nowyarn create react-app another-app --typescript --use-pnp
works too and I could not reproduce the issue anymore.TL;DR; Run
yarn install
twice. πUpdating workaround from @Ciantic β¦
VSCode seems to use the workspace sdk when βtypescript.tsdkβ is set appropriately
Iβm still getting this issue. When I try using @Cianticβs workaround, I get #10002 instead. Iβm kind of at a loss for words; regardless of which version of yarn I use or how I invoke the various commands, yarn+pnp+typescript really doesnβt want to work with create-react-app for me.
Is this in 3.0.1? It says it is in the release notes but the error is still there.
Any chance of seeing this land on 3.0 ? This would be really helpful, my team is getting depressed because of the long install times on our monorepoβ¦