无法读取未定义的 CompileError 的属性“类型":始于未定义的 CSS 选择器“npm run build" [英] Cannot read property 'type' of undefined CompileError: Begins at CSS selector undefined `npm run build`

查看:70
本文介绍了无法读取未定义的 CompileError 的属性“类型":始于未定义的 CSS 选择器“npm run build"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的 create-react-app 项目中执行 npm run build 时,它失败并且登录不是很有帮助.

When I am doing npm run build in my create-react-app project, it is failing and the log in not very helpful.

这里 ->npm 日志的图像

这里是文本格式的问题.

Here is the problem in text format.

> react-scripts build

Creating an optimized production build...
Failed to compile.

Cannot read property 'type' of undefined
CompileError: Begins at CSS selector undefined


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! card_builder@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the card_builder@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in

我的应用在开发模式下运行良好(即在 npm start)

这里是代码沙箱url的链接->https://Codesandbox.io/s/cant-read-propery-type-of-undefined-problem-with-react-scripts-build-6riyp

Here is the link of the code sandbox url -> https://codesandbox.io/s/cant-read-propery-type-of-undefined-problem-with-react-scripts-build-6riyp

使用 create-react-app 构建

推荐答案

这种错误很可能来自某个地方的空 CSS 规则.它可能来自依赖项,因此可能会变得棘手.

This kind of error might comes from an empty CSS rule somewhere, most probably. It might come from a dependency, so that might get tricky.

首先要做的是尝试从项目中一个一个地删除 css 文件,以找出问题所在.如果你找不到它,那么它来自一个依赖项,你最好的办法是从 CSSLint 或你正在使用的 linter 中删除 empty-rules 规则.

First thing to do would be to try to remove css file one by one from your project to spot which one as the issue. If you can't find it, then it comes from a dependency, and you best bet would be to remove empty-rules rule from CSSLint or from the linter you are using.

资源:https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules

这篇关于无法读取未定义的 CompileError 的属性“类型":始于未定义的 CSS 选择器“npm run build"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆