我使用 create-react-app 创建了一个应用程序并且在尝试构建生产优化版本时遇到错误 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.
不幸的是,这不是一个非常有用的错误。谷歌搜索似乎找到了关于 postcss 的内容但我不确定这与 create-react-app 有什么关系,或者如何解决这个问题。
有没有人遇到过类似的问题?
请注意,该应用程序在开发模式下可以正常编译:
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.
最佳答案
错误消息“需要伪类或伪元素。”可能会在导入的 CSS 文件之一中提示伪类的一些语法错误。
例如:
**header nav li:last-child {
margin-right: 0;
}**
被写成:
**header nav li: last-child {
margin-right: 0;
}**
关于创建 react 应用程序构建错误 "Expected a pseudo-class or pseudo-element.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53185678/