You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Reacted by ZHAO Jin-Xiang, Nicky Hajal, Pat, Celso Marciano, Lofty Snowman, blagodus, Dusan Blagojevic, Hugo Meissner, Joscha Alisch, Hunter Beast and 31 more
No it's actually a bit easier in this case. TypeScript support for tsc (and vscode) is currently blocked by microsoft/TypeScript#28289, but that's only for the tsc command line tool. The Webpack plugins aren't necessarily affected.
So having pnp support inside the TS compilers is doable. It's already in ts-loader, and fork-ts-checker-webpack-plugin (that create-react-app uses under the hood) already has an intent of implement (TypeStrong/fork-ts-checker-webpack-plugin#181). Just remains making the PR itself ☺️
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...
I'm a bit short on time with the work on Yarn v2 and personal stuff, but I can offer advices and review time if you want to implement the resolveModuleName feature in fork-ts-checker-webpack-plugin!
Once merged I'll make another one to create-react-app to upgrade fork-ts-checker-webpack-plugin and add support for the resolvers 🙂
Reacted by Ian Sutherland, Ian Schmitz, nhducit, Kamil Kiewisz, ZHAO Jin-Xiang, John Reilly, Bond, Vincent Lecrubier, Drew Dennison, Jan Killian and 6 more
@NullVoxPopuli Yes but as you just saw in microsoft/TypeScript#28289 this does not seem like it is going to happen anytime soon, so I guess moving on with the proposed fix is the way to go.
Is this in 3.0.1? It says it is in the release notes but the error is still there.
yarn run v1.16.0
$ react-scripts start
C:\personal-projs\we-there-yet-qm\.pnp.js:15914
throw firstError;
^Error: Cannot find module 'react-dev-utils/crossSpawn'
Require stack:
- C:\Users\alaam\AppData\Local\Yarn\cache\v4\npm-react-scripts-3.0.1-e5565350d8069cc9966b5998d3fe3befe3d243ac\node_modules\react-scripts\bin\react-scripts.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
at Function.Module._resolveFilename (C:\personal-projs\we-there-yet-qm\.pnp.js:15871:44)
at callNativeResolution (C:\personal-projs\we-there-yet-qm\.pnp.js:15476:19)
at Object.resolveToUnqualified (C:\personal-projs\we-there-yet-qm\.pnp.js:15593:22)
at Object.resolveRequest (C:\personal-projs\we-there-yet-qm\.pnp.js:15723:31)
at Function.Module._resolveFilename (C:\personal-projs\we-there-yet-qm\.pnp.js:15905:30)
at Function.Module._load (C:\personal-projs\we-there-yet-qm\.pnp.js:15821:31)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (C:\Users\alaam\AppData\Local\Yarn\cache\v4\npm-react-scripts-3.0.1-e5565350d8069cc9966b5998d3fe3befe3d243ac\node_modules\react-scripts\bin\react-scripts.js:18:15)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@alaatm I've got similar error when I run yarn create react-app another-app --typescript --use-pnp. I've run yarn create react-app another-app --typescript instead and then yarn --pnp. Then I've got exactly the same error so I run yarn install. Did not helped so I run it again as I was expecting to see success Already up-to-date but it seems that with pnp it always go through all the steps. This made yarn run start run. There were any changes to yarn.lock nor .pnp.js files. Now yarn create react-app another-app --typescript --use-pnp works too and I could not reproduce the issue anymore.
yarn set version berry
yarn dlx create-react-app --template typescript my-app
cd my-app
yarn add @yarnpkg/pnpify -D
yarn pnpify --sdk
// Open with vscode
// Go to currently broken tsx file
// Hit Ctrl+Shift+P, choose selectTypescript version -> Use Workspace Version Pnipify
// Reload Vscode window
// Finally you might want to remove extra files from the root
// Then run `yarn set version berry`in my-app too
Reacted by 牛さん
Reacted by Dominik Lekse, Daniel Maia, Jonny Pickard and Luiz
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.
Activity
add typescript react/create-react-app#5647
hmeissner commentedon Nov 9, 2018
The problem is that even if we get around the
typescript missingerror, I think the solution will still be blocked by microsoft/TypeScript#28289arcanis commentedon Nov 9, 2018
No it's actually a bit easier in this case. TypeScript support for
tsc(and vscode) is currently blocked by microsoft/TypeScript#28289, but that's only for thetsccommand line tool. The Webpack plugins aren't necessarily affected.So having pnp support inside the TS compilers is doable. It's already in☺️
ts-loader, andfork-ts-checker-webpack-plugin(thatcreate-react-appuses under the hood) already has an intent of implement (TypeStrong/fork-ts-checker-webpack-plugin#181). Just remains making the PR itselfhronro commentedon Dec 13, 2018
Any updates?
arcanis commentedon Dec 13, 2018
I haven't had the time yet to work on TypeStrong/fork-ts-checker-webpack-plugin#181 - it would be awesome if someone could help on this (I've already made a similar PR on ts-loader that can be used as inspiration: TypeStrong/ts-loader#862).
crubier commentedon Apr 7, 2019
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...
arcanis commentedon Apr 7, 2019
I'm a bit short on time with the work on Yarn v2 and personal stuff, but I can offer advices and review time if you want to implement the
resolveModuleNamefeature infork-ts-checker-webpack-plugin!arcanis commentedon Apr 18, 2019
I found the time and pushed a PR: TypeStrong/fork-ts-checker-webpack-plugin#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 🙂
arcanis commentedon Apr 20, 2019
PR up at #6856
NullVoxPopuli commentedon Apr 24, 2019
The solution for this shouldn't be in webpack, but in tsc and typescript-language-server. :-\
crubier commentedon Apr 25, 2019
@NullVoxPopuli Yes but as you just saw in microsoft/TypeScript#28289 this does not seem like it is going to happen anytime soon, so I guess moving on with the proposed fix is the way to go.
alaatm commentedon May 10, 2019
Is this in 3.0.1? It says it is in the release notes but the error is still there.
damianfijorek commentedon Jun 1, 2019
@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 --typescriptinstead 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-datebut it seems that withpnpit always go through all the steps. This madeyarn run startrun. There were any changes toyarn.locknor.pnp.jsfiles. Nowyarn create react-app another-app --typescript --use-pnpworks too and I could not reproduce the issue anymore.TL;DR; Run
yarn installtwice. 😃alaatm commentedon Jun 3, 2019
@damianfijorek That's weird, but the workaround did not work for me -.-
iki commentedon Jul 26, 2019
yarn@1.12.3 with create-react-app@3.0.1 in node 10 on win 10 fails for me:
and the same on node 12.7 fails differently:
Ciantic commentedon Mar 6, 2020
This works but is needlessly complicated:
tydira commentedon Nov 3, 2020
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.
teyc commentedon Nov 5, 2021
Updating workaround from @Ciantic ....
VSCode seems to use the workspace sdk when "typescript.tsdk" is set appropriately