角度构建错误:TypeError:不能读取未定义的属性'line'

时间:2022-06-13 19:42:37

I am suddenly facing build fail error for production. I am running this command:

我突然面临生产中的构建失败错误。我运行以下命令:

ng build --prod

and getting following error:

得到以下错误:

D:\a\1\s\node_modules\clean-css\lib\reader\input-source-map-

tracker.js:37
  if (originalPosition.line === null && line > 1 && selectorFallbacks > 0) {
                      ^
TypeError: Cannot read property 'line' of undefined
    at originalPositionFor (D:\a\1\s\node_modules\clean-css\lib\reader\input-source-map-tracker.js:37:23)
    at originalMetadata (D:\a\1\s\node_modules\clean-css\lib\tokenizer\tokenize.js:486:43)
    at intoTokens (D:\a\1\s\node_modules\clean-css\lib\tokenizer\tokenize.js:435:68)
    at tokenize (D:\a\1\s\node_modules\clean-css\lib\tokenizer\tokenize.js:74:10)
    at fromStyles (D:\a\1\s\node_modules\clean-css\lib\reader\read-sources.js:147:12)
    at fromString (D:\a\1\s\node_modules\clean-css\lib\reader\read-sources.js:48:10)
    at doReadSources (D:\a\1\s\node_modules\clean-css\lib\reader\read-sources.js:33:12)
    at readSources (D:\a\1\s\node_modules\clean-css\lib\reader\read-sources.js:24:10)
    at D:\a\1\s\node_modules\clean-css\lib\clean.js:99:12
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
Error: C:\Program Files\Git\bin\bash.exe failed with return code: 1

It used to work fine a few days ago but suddenly stopped working. Does any body have idea that why is this happening?

几天前它还可以正常工作,但突然就不工作了。有没有人知道为什么会这样?

(I am using angular cli version 1.6.7)

(我使用的是角cli版本1.6.7)

Thanks in advance

谢谢提前

3 个解决方案

#1


0  

Alright! It's confirmed that this is happening in latest version of angular cli.

好吧!这在最新版本的角cli中得到了证实。

I finally fixed my issue by lowering version to 1.6.7 and by removing ^ I was facing this issue even after lowering version:

我终于固定我的问题通过降低版本1.6.7和通过消除^我面临这个问题即使降低版本:

"@angular/cli": "^1.6.7"

:“@angular / cli ^ 1.6.7”

Then I removed ^ to fix the cli version and now it works fine.

然后我删除^修复cli版本和现在工作正常。

I request angular team that please fix this angular cli issue so that we can use latest versions.

我请求角团队,请修复这个角cli问题,以便我们可以使用最新版本。

I hope this would help.

我希望这能有所帮助。

#2


0  

While it seems clean-css is failing fantastically after @angular/cli 1.6.7, this issue can be resolved for later versions of @angular/cli, regardless.

尽管在@棱角/cli 1.6.7之后,看起来清晰的css在不可思议地失败了,但是这个问题可以在以后的@棱角/cli版本中得到解决,无论如何。

I got a lead on this issue being caused by non-breaking spaces: https://github.com/jakubpawlowicz/clean-css/issues/1006

在这个问题上,我得到了一个线索:https://github.com/jakubpawlowicz/css/es/1006。

I was then able to resolve the issue by opening the src/ folder as a workspace in Notepad++, filtering on *.scss and *.css, and doing a search with Regex on using \xA0 to find non-breaking spaces in the scss/css files; I found one. Once removed, my error went away.

然后我就可以通过在Notepad++中打开src/文件夹作为工作区来解决这个问题,在*上进行过滤。scss和*。使用Regex使用\xA0搜索scss/css文件中的非中断空间;我发现一个。一旦被删除,我的错误就消失了。

#3


-1  

Issue got resolved

问题得到了解决

ng build --env=prod solves the problem no need to downgrade angular cli version

ng构建——env=prod解决了问题,不需要降级角cli版本。

#1


0  

Alright! It's confirmed that this is happening in latest version of angular cli.

好吧!这在最新版本的角cli中得到了证实。

I finally fixed my issue by lowering version to 1.6.7 and by removing ^ I was facing this issue even after lowering version:

我终于固定我的问题通过降低版本1.6.7和通过消除^我面临这个问题即使降低版本:

"@angular/cli": "^1.6.7"

:“@angular / cli ^ 1.6.7”

Then I removed ^ to fix the cli version and now it works fine.

然后我删除^修复cli版本和现在工作正常。

I request angular team that please fix this angular cli issue so that we can use latest versions.

我请求角团队,请修复这个角cli问题,以便我们可以使用最新版本。

I hope this would help.

我希望这能有所帮助。

#2


0  

While it seems clean-css is failing fantastically after @angular/cli 1.6.7, this issue can be resolved for later versions of @angular/cli, regardless.

尽管在@棱角/cli 1.6.7之后,看起来清晰的css在不可思议地失败了,但是这个问题可以在以后的@棱角/cli版本中得到解决,无论如何。

I got a lead on this issue being caused by non-breaking spaces: https://github.com/jakubpawlowicz/clean-css/issues/1006

在这个问题上,我得到了一个线索:https://github.com/jakubpawlowicz/css/es/1006。

I was then able to resolve the issue by opening the src/ folder as a workspace in Notepad++, filtering on *.scss and *.css, and doing a search with Regex on using \xA0 to find non-breaking spaces in the scss/css files; I found one. Once removed, my error went away.

然后我就可以通过在Notepad++中打开src/文件夹作为工作区来解决这个问题,在*上进行过滤。scss和*。使用Regex使用\xA0搜索scss/css文件中的非中断空间;我发现一个。一旦被删除,我的错误就消失了。

#3


-1  

Issue got resolved

问题得到了解决

ng build --env=prod solves the problem no need to downgrade angular cli version

ng构建——env=prod解决了问题,不需要降级角cli版本。