create-react-app build error "Expected a pseudo-class or pseudo-element."

Viewed 5966

I create a app using create-react-app and am encountering an error when trying to build a production-optimized version yarn build:

> yarn build help
yarn run v1.9.4
$ react-scripts build help
Creating an optimized production build...
Failed to compile.

Expected a pseudo-class or pseudo-element.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is unfortunately not a very useful error. Googling around for it seems to turn-up stuff about postcss but I'm not sure exactly how that's related to create-react-app, or how to go about resolving the issue.

Has anyone encountered similar issues before?


Note that the app compiles fine in dev mode:

Compiled successfully!

You can now view note-app in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://192.168.0.54:3000/

Note that the development build is not optimized.
To create a production build, use yarn build.
2 Answers

Error message 'Expected a pseudo-class or pseudo-element.' may suggest some syntax error of pseudo-classes in one of the CSS files imported.

For example:

**header nav li:last-child {
    margin-right: 0;
}**

were wrote as:

**header nav li: last-child {
    margin-right: 0;
}**

It indicates there's a syntax error in one of the css files imported in the project. For example - //

Related