Angular - 错误:PostCSS 收到未定义而不是 CSS 字符串 [英] Angular - ERROR: PostCSS received undefined instead of CSS string

查看:126
本文介绍了Angular - 错误:PostCSS 收到未定义而不是 CSS 字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试构建一个 Angular 项目,但出现以下错误.这个项目上周建得很好.我对使用该项目中的 Dll 的其他项目进行了一些更改,但对该项目没有任何更改.我已经花了很多时间对其进行故障排除,但运气不佳,非常感谢您的帮助.

Trying to build an Angular project and I'm getting below errors. This project was built fine last week. I made some changes to other projects that use the Dlls from this project, but no changes to this project. I already spent a lot of time troubleshooting it with no luck and appreciate any help.

错误:PostCSS 收到未定义而不是 CSS 字符串发生未处理的异常:PostCSS 接收到 undefined 而不是 CSS 字符串

ERROR: PostCSS received undefined instead of CSS string An unhandled exception occurred: PostCSS received undefined instead of CSS string

推荐答案

我遇到了类似的问题.我正在尝试构建一个角度库,但出现以下消息:

I had similar problem. I was trying to build an angular library and the message below appeared:

Building Angular Package

------------------------------------------------------------------------------
Building entry point 'library-name'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
ERROR: PostCSS received undefined instead of CSS string
An unhandled exception occurred: PostCSS received undefined instead of CSS string
See "/tmp/ng-itlEgm/angular-errors.log" for further details.
[12:03:38] 'compile' errored after 17 s
[12:03:38] Error: Command `ng build library-name --prod` exited with code 127
    at ChildProcess.handleSubShellExit (/node_modules/gulp-run/command.js:166:13)
    at Object.onceWrapper (events.js:422:26)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:505:15)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
[12:03:38] 'build' errored after 17 s

我使用 gulp-run 来执行命令 ng build library-name --prod.但是,直接在终端执行命令ng build library-name --prod,日志错误较小,但也类似.

I was using gulp-run to execute the command ng build library-name --prod. But, executing the command ng build library-name --prod directly on the terminal, the log error was smaller, but similar too.

问题出在一个组件上.该组件有一个 styleURL(Angular 组件装饰器),如下所示:

The problem was in one component. The component had one styleURL (Angular component decorator), like this:

...component.css

但是,库使用 scss.所以,我将路径更改为:

but, the library uses scss. So, I changed the path to:

...component.scss

然后我执行了命令ng build library-name --prod".所以,错误没有再次出现.

and I executed the command 'ng build library-name --prod'. So, the error didn't appear again.

我使用的是 NVM v0.35.2(允许在我的机器上安装多个 NodeJS 版本);NodeJS v12.18.2;Ubuntu x64 18.0.4 LTS 和 Angular CLI 9.1.9.

I was using NVM v0.35.2 (allow to have more than one NodeJS version installed in my machine); NodeJS v12.18.2; Ubuntu x64 18.0.4 LTS and Angular CLI 9.1.9.

这篇关于Angular - 错误:PostCSS 收到未定义而不是 CSS 字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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