我使用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.
答案 0 :(得分:0)
错误消息“预期为伪类或伪元素。”可能会在导入的一个CSS文件中提示伪类的某些语法错误。
例如:
**header nav li:last-child {
margin-right: 0;
}**
被写为:
**header nav li: last-child {
margin-right: 0;
}**