Skip to content

Initiate AOT compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings. Angular 4 #6002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xtianus79 opened this issue Apr 18, 2017 · 7 comments

Comments

@xtianus79
Copy link

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Output from: ng --version.
"@angular/compiler-cli": "4.0.2",

node v7.9.0
macOS ( Sierra?)

Simple steps to reproduce this bug.
Please include: commands run, packages added, related code changes.
A link to a sample repo would help too.

following the steps here https://angular.io/docs/ts/latest/cookbook/aot-compiler.html
this command is run:
node_modules/.bin/ngc -p tsconfig-aot.json

The log given by the failure.

Error: Expected 'styleUrls' to be an array of strings.
at assertArrayOfStrings (/Users/xxxxx/xxxxx/xxxxx/xxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:3361:19)
at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (/Users/xxxxx/xxxxx/xxxxx/xxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:13786:13)
at CompileMetadataResolver._getEntryComponentMetadata (/Users/xxxxx/xxxxx/xxxxx/xxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:14484:45)
at /Users/xxxxx/xxxxx/xxxxx/xxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:14470:48
at Array.forEach (native)
at CompileMetadataResolver._getEntryComponentsFromProvider (/Users/xxxxx/xxxxx/xxxxx/xxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:14469:30)
at /Users/xxxxx/xxxxxx/xxxxx/frontend/node_modules/@angular/compiler/bundles/compiler.umd.js:14433:83
at Array.forEach (native)
at CompileMetadataResolver._getProvidersMetadata (/Users/xxxxxxx/xxxxxx/xxxxxxx/xxxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:14397:19)
at /Users/xxxxxx/xxxxxxxxx/xxxxxxx/xxxxxx/node_modules/@angular/compiler/bundles/compiler.umd.js:14399:23
Compilation failed

Desired functionality.

it should work

Mention any other details that might be useful.

I am using angular 4.0.2 and it's components

@xtianus79 xtianus79 changed the title Initiate AOT compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings Initiate AOT in Angular 4 compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings Apr 18, 2017
@xtianus79 xtianus79 changed the title Initiate AOT in Angular 4 compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings Initiate AOT compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings in Angular 4 Apr 18, 2017
@xtianus79 xtianus79 changed the title Initiate AOT compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings in Angular 4 Initiate AOT compilation from the command line using ngc is failing Error : Expected 'stylesUrls' to be an array of strings. Angular 4 Apr 18, 2017
@clydin
Copy link
Member

clydin commented Apr 18, 2017

The CLI (ng ...) handles the details of AOT compilation.
Create a new project via ng new aot-test (for example) then execute ng build --prod from within the project directory. (AOT is enabled by default with a production build). The dist directory will contain the AOT compiled and optimized output.

@xtianus79
Copy link
Author

@clydin this is using AOT that is in an existing project. What help does your instructions provide?

@clydin
Copy link
Member

clydin commented Apr 18, 2017

if you are not using the CLI then the appropriate repository to open an issue concerning your problem is angular/angular which maintains the 'ngc' tool.

@xtianus79
Copy link
Author

xtianus79 commented Apr 18, 2017

@clydin I am using the cli... I am not sure how to segregate out the ngc tool. this seems to be an issue deriving from cli through typescript

@clydin sorry I see what you are saying but from my understanding ngc is an equal tpc replacement from the cli... I didn't install ngc for example.

@filipesilva
Copy link
Contributor

On CLI projects you don't use ngc directly, you use ng build instead. The instructions in https://angular.io/docs/ts/latest/cookbook/aot-compiler.html are not for CLI projects, but rather projects like https://github.com/angular/quickstart.

@RonNewcomb
Copy link

Late to the party, but I had this issue caused by including a css file twice, once in the angular-cli.json's styles array, and once in a particular component's styleUrls array. Apparently the cli's webpack sees the filename/filepath that it already recognizes in the component and wraps/replaces the filepath string with something like __webpack__require(filepath) which is obviously not the string the styleUrls property was looking for.

Fix is to remove it from one of those locations. (Assuming you don't have it on multiple components. In that case, remove it from angular-cli.json)

Even a slight change to the filepath could fix it. Changing one of them from xxx.min.css to just xxx.css would cure the error, even though you wouldn't want it twice in your project.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants