Skip to content

Opaque error for invalid CSS after upgrade: TypeError: Cannot read property '0' of undefined #6282

Closed

Description

@buildbreakdo

After upgrading from react-scripts 1.1.4 to 2.1.3 see an opaque error message when trying to build:

Error in   TypeError: Cannot read property '0' of undefined

Thought this might be related to #2069 (determined to be bug of package managers?), but after trial and error determined it was related to invalid CSS.

Reproduce (react-scripts 2.1.3):

  1. Add invalid CSS to any .css file, like:
label[for=*] {
  margin-right: 12px;
}
  1. yarn build

Output:

Error in   TypeError: Cannot read property '0' of undefined

This invalid CSS does not produce a build error in react-scripts 1.1.4, so this is something people will bump into when they upgrade and not really know what to do (e.g., claim the upgraded version is broken).

Activity

  1. mrmckeb commented on Jan 30, 2019

    @mrmckeb
    Contributor

    Interesting, that is a mysterious error message @buildbreakdo. Thanks for tracking down the cause.

    Was it telling you that a JS or CSS file had an error? Can you supply an example in a repo? Thanks!

  2. self-assigned this
    on Jan 30, 2019
  3. buildbreakdo commented on Feb 4, 2019

    @buildbreakdo
    ContributorAuthor

    @mrmckeb Yes, indeed it is! This is what the full output looks like:

    screen shot 2019-02-04 at 2 02 14 pm

    Here is an example repo:
    https://github.com/buildbreakdo/css-breaks-create-react-app-demo

    Clone and yarn build to see the error message. Line that causes this is here (invalid CSS):
    https://github.com/buildbreakdo/css-breaks-create-react-app-demo/blob/master/src/App.css

  4. mrmckeb commented on Feb 5, 2019

    @mrmckeb
    Contributor

    OK, so it looks like this need to be properly investigated ad solved. Would you be able to raise a PR? If not, we can leave it open for someone to pick up (perhaps me on the weekend).

    Thanks for the repo too, that's great help.

  5. buildbreakdo commented on Feb 5, 2019

    @buildbreakdo
    ContributorAuthor

    @mrmckeb Yes, I'll give it a go, see if I can get a PR in sometime this week.

  6. buildbreakdo commented on Feb 6, 2019

    @buildbreakdo
    ContributorAuthor

    @mrmckeb Pull request with a fix is in

  7. locked and limited conversation to collaborators on Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions