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

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

Closed
buildbreakdo opened this issue Jan 26, 2019 · 5 comments · Fixed by #6352

Comments

@buildbreakdo
Copy link
Contributor

buildbreakdo commented Jan 26, 2019

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).

@mrmckeb
Copy link
Contributor

mrmckeb commented Jan 30, 2019

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!

@buildbreakdo
Copy link
Contributor Author

buildbreakdo commented Feb 4, 2019

@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

@mrmckeb
Copy link
Contributor

mrmckeb commented Feb 5, 2019

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.

@buildbreakdo
Copy link
Contributor Author

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

@buildbreakdo
Copy link
Contributor Author

@mrmckeb Pull request with a fix is in

iansu pushed a commit that referenced this issue Oct 23, 2019
* Add additional information for postcss errors

* Add additional information for postcss errors (simplify)

* Remove chunkname from postCSS compile error

* Remove line number from postCSS compile error
@lock lock bot locked and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants