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
{{ message }}
Repository navigation
Cannot find module './logo.svg' using custom react-scripts and Typescript template #8223
When I forked this repo and re-published version 3.3.0 of react-scripts (WITHOUT ANY CHANGES!) under my own organization on npmjs, I was unable to successfully build/start a project using these custom scripts.
Just wanted to comment here that this is still an issue as of v3.4.1. If I checkout v3.4.1, go to packages/react-scripts, rename the package and publish it (no other modifications), and create a React app using something like:
then CRA will still add a react-app-env.d.ts file with the following:
/// <reference types="react-scripts" />
and the logo will thus fail to be imported, since the default react-scripts is not present in the project at this point.
If I manually change "react-scripts" here to the name of my custom react-scripts, SVGs can be detected again.
I am curious as to at which point during the project creation process this file gets added, and whether it can be configured to reference the custom react-scripts name instead.
I just ran into this issue and was able to change the react-app-env.d.ts file in the template by making this change to /packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js. Which fixed the Cannot find module './logo.svg' or its corresponding type declarations. error for me.
I just ran into this issue and was able to change the react-app-env.d.ts file in the template by making this change to /packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js. Which fixed the Cannot find module './logo.svg' or its corresponding type declarations. error for me.
There's a similar fix in the PR listed in my original issue. It was closed by @mrmckeb in #5827 (comment) in favor of #5877 but both PRs have been closed. I assume the first one shouldn't have been closed, knowing that the 2nd one wouldn't be merged?
Maybe we could create a new PR for this
Copy code from react-scripts/lib/react-app.d.ts to YOUR_PROJ/src/react-app-env.d.ts would help.
Reacted by Ainur, Jordan Soltman, GertValiakhmetov, Ahmad Maged, Fabien Cohen, idbd, George Yong, Raffaele Garofalo, Mattias Fjellvang, Peter Almos Unyi and 1 more
Reacted by Ainur, Jordan Soltman, GertValiakhmetov, George Yong and Nathan Christos
Reacted by Ainur, Jordan Soltman, GertValiakhmetov and George Yong
Reacted by Ainur, Jordan Soltman, GertValiakhmetov, George Yong and Raffaele Garofalo
Activity
IvanCaceres commentedon Mar 2, 2020
Applying that fix resolved the issue for me, thanks @DalderupMaurice !
This issue still occurs when forking your own CRA.
ahmad2smile commentedon Jul 1, 2020
For me it was eslint deciding to lint
react-app-env.d.ts.Fixed it from
To:
NOTE: the space b/w first too forward slashes.
Coteh commentedon Aug 24, 2020
Just wanted to comment here that this is still an issue as of v3.4.1. If I checkout v3.4.1, go to
packages/react-scripts, rename the package and publish it (no other modifications), and create a React app using something like:then CRA will still add a
react-app-env.d.tsfile with the following:and the logo will thus fail to be imported, since the default
react-scriptsis not present in the project at this point.If I manually change
"react-scripts"here to the name of my customreact-scripts, SVGs can be detected again.I am curious as to at which point during the project creation process this file gets added, and whether it can be configured to reference the custom
react-scriptsname instead.lerickson-ds commentedon Oct 21, 2020
I just ran into this issue and was able to change the react-app-env.d.ts file in the template by making this change to /packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js. Which fixed the
Cannot find module './logo.svg' or its corresponding type declarations.error for me.to
DalderupMaurice commentedon Oct 22, 2020
There's a similar fix in the PR listed in my original issue. It was closed by @mrmckeb in #5827 (comment) in favor of #5877 but both PRs have been closed. I assume the first one shouldn't have been closed, knowing that the 2nd one wouldn't be merged?
Maybe we could create a new PR for this
dylannil commentedon Nov 16, 2020
Copy code from
react-scripts/lib/react-app.d.tstoYOUR_PROJ/src/react-app-env.d.tswould help.manuartero commentedon Jun 1, 2022
Isn't there any option at the
tsconfig.jsonto explicitly say"ey buddy, check this .d.ts file" ?
I've tried using
referencesbut that doesn't work.(Actually I'm 90% sure there isn't such option at
tsconfig.jsonsince I've spent some time reading each key, but... 🤞 you never know )