Angular-cli: ng build --prod failed - TypeError: Cannot read property '1' of undefined

Created on 28 Feb 2018  路  9Comments  路  Source: angular/angular-cli

It work very well in develop mode (ng serve), but I can't build to production

Versions

Angular CLI: 1.7.1
Node: 6.13.0
OS: linux x64
Angular: 5.2.6
@ angular/cdk: 2.0.0-beta.12
@ angular/cli: 1.7.1
@ angular-devkit/build-optimizer : 0.3.2
@ angular-devkit/core: 0.3.2
@ angular-devkit/schematics : 0.3.2
@ ngtools/json-schema : 1.1.0
@ ngtools/webpack : 1.10.1
@ schematics/angular : 0.3.2
@ schematics/package-update : 0.3.2
typescript : 2.5.3
webpack : 3.11.0

Repro steps

ng build --prod

The log given by the failure

10% building modules 6/6 modules 0 active/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js:30
throw e;
^
TypeError: Cannot read property '1' of undefined at Object.font [as breakUp] (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/optimizer/level-2/break-up.js:308:66)
at populateComponents (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js:17:42)
at optimizeProperties (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js:19:3)
at recursivelyOptimizeProperties (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/optimizer/level-2/optimize.js:63:9)
at level2Optimize (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/optimizer/level-2/optimize.js:77:3)
at optimize (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/clean.js:131:5)
at /home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/clean.js:104:29
at /home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:26:64
at loadOriginalSources (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/load-original-sources.js:26:5)
at /home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:26:14
at applySourceMaps (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/apply-source-maps.js:34:5)
at /home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:25:12
at fromStyles (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:152:5)
at fromString (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:48:10)
at doReadSources (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:33:12)
at readSources (/home/rafael/Documents/bimweb-spa/bimweb-spa/node_modules/clean-css/lib/reader/read-sources.js:24:10)

Desired behavior

Trying to create a production build to deploy to S3.

Most helpful comment

Downgrading @angular/cli to 1.6.8 works for me ! The problem is present since the 1.7.0 version

All 9 comments

@RafaelFronteira Same for me, i'm struggling to find what's causing this.
Did you manage to ?

I can see it's a font problem
I tried removing all the css file inclusion one by one in .angular-cli.json but with no chance.

@comemanu I still can not solve...
I removing all the css file too, but the problem don't seems to be in them.
I'll try isolate all the components and testing one by one.

@RafaelFronteira
I changed all my angular/xxx versions in my package.json.
To do that i installed a new empty angular project with "ng new ..." , and then pick all the versions of the new projects and replaced in my not working project , run "npm install"
Now when i try to build --prod , the is an explicit error telling me can't resolve a css file relative to a font.
So now i know what was causing this.

@comemanu What's the error that appears for you?
Maybe we can solve this problem together.

Downgrading @angular/cli to 1.6.8 works for me ! The problem is present since the 1.7.0 version

@hdayacr The solution worked for me!!!
It's alive!

@RafaelFronteira,
Hi,
1.7.2 fixed the problem in my case :)

Thanks, @kevincaradant!

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings