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

CRA4 build error #9696

Closed
waynebrantley opened this issue Sep 24, 2020 · 4 comments · Fixed by #10213
Closed

CRA4 build error #9696

waynebrantley opened this issue Sep 24, 2020 · 4 comments · Fixed by #10213

Comments

@waynebrantley
Copy link

Existing working typescript based CRA 3.4.x application.

Upgrade to 4.0.0.next.98 react-scripts

when building it gives an error of:

./src/images/shared/logowords.svg (./node_modules/@svgr/webpack/lib?-svgo,+titleProp,+ref!./src/images/shared/logowords.svg)
TypeError: Cannot read property 'tagName' of null

This happens locally and on a clean build server.

@vonkanehoffen
Copy link

I'm also seeing this on 4.0.0

The same SVG loads fine with

import { ReactComponent as HomeIcon } from "./home.svg";

when I test with a newly created, vanilla CRA though, so I guess it must be something to do with another dependency I have in my main project

@waynebrantley
Copy link
Author

With the 4.0.0 release, I experienced this too at first..but through hook and crook, removing node_modules folders, using yarn, etc - eventually it went away. So definitely will work and is related to other module issues.

@fsp
Copy link

fsp commented Nov 25, 2020

The following fixed it for me:

npm install @svgr/webpack --save-dev

jabranr added a commit to jabranr/create-react-app that referenced this issue Dec 7, 2020
@aqumus
Copy link

aqumus commented May 4, 2021

I faced similar issue upgrading from CRA v3.4.3 to v4.0.3 where importing svg in component as

import { ReactComponent as SmileyIcon } from './smiley.svg'

was throwing error
ReactComponent is not exported from @svgr/webpack

Looks like I also had other dependencies which were pulling old version of @svgr/webpack (v2.2.0),
Added resolutions to the root monorepo package.json to make sure there's single version of @svgr/webpack (v5.5.0)

// root package.json

  "resolutions": {
    "**/@svgr/webpack": "^5.5.0"
  },

or could follow @fsp suggestion stated above

The following fixed it for me:
npm install @svgr/webpack --save-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants