Angular-cli: viewEncapsulation is not defined

Created on 24 Nov 2016  路  13Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Mac OSX el capitan

Mac OSX el capitan

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.21
node: 6.6.0
os: darwin x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

Ran command ng g component purchase-leads

The log given by the failure.

Normally this include a stack trace and some more information.

viewEncapsulation is not defined (Error in blueprint template: /Users/ritz078/projects/housing-assist/node_modules/angular-cli/blueprints/component/files/__path__/__name__.component.ts)
ReferenceError: viewEncapsulation is not defined (Error in blueprint template: /Users/ritz078/projects/housing-assist/node_modules/angular-cli/blueprints/component/files/__path__/__name__.component.ts)
    at eval (eval at <anonymous> (/Users/ritz078/projects/housing-assist/node_modules/lodash/template.js:225:12), <anonymous>:9:5)
    at processTemplate (/Users/ritz078/projects/housing-assist/node_modules/angular-cli/angular-cli/lib/models/file-info.js:20:36)
    at /Users/ritz078/projects/housing-assist/node_modules/angular-cli/angular-cli/lib/models/file-info.js:97:20
    at tryCatch (/Users/ritz078/projects/housing-assist/node_modules/rsvp/dist/lib/rsvp/-internal.js:215:12)
    at invokeCallback (/Users/ritz078/projects/housing-assist/node_modules/rsvp/dist/lib/rsvp/-internal.js:230:13)
    at publish (/Users/ritz078/projects/housing-assist/node_modules/rsvp/dist/lib/rsvp/-internal.js:198:7)
    at flush (/Users/ritz078/projects/housing-assist/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

1 (urgent) bufix

Most helpful comment

Change .angular-cli.json like this, working on 1.0.0

  "defaults": {
    "styleExt": "css",
    "component": {
      "viewEncapsulation": "Emulated",
      "changeDetection": "Default"
    }
  }

All 13 comments

I have the same issue with..

angular-cli: 1.0.0-beta.20-4
node: 4.2.6
os: linux x64

Any idea what happend in the last changes? Two weak ago everythinks works fine..

edit: npm link angular-cli in root dir was help me.. now works good

I am also getting this when trying to generate a component. It started on beta.20-4 for me.

angular-cli: 1.0.0-beta.21
node: 6.9.1
os: win32 x64

I think it may have broken by this feature: #2822

You can kludge around it by adding

        "viewEncapsulation": "Emulated",
        "changeDetection": "Default",

to the "defaults" section of your angular-cli.json. It's supposed to leave out those properties in the new component if the defaults aren't specified, but instead it crashes.

angular-cli: 1.0.0-beta.21
node: 5.12.0
os: win32 x64

I could not get the error in either a new or existing project.

As of my last update of Angular CLI, I am also receiving this error when generating components.

angular-cli: 1.0.0-beta.20-4 node: 4.5.0 os: darwin x64

i have same issue,

ng generate component test1 installing component Error locating module for declaration SilentError: Multiple module files found:

when i try to use '--skip-import', i'm also receive this error.

then i try to use @teledemic advise
"viewEncapsulation": "Emulated", "changeDetection": "Default",
i got:
ng generate component "test1" --skip-import installing component identical src\app\test1\test1.component.css identical src\app\test1\test1.component.html identical src\app\test1\test1.component.spec.ts identical src\app\test1\test1.component.ts Path must be a string. Received undefined

angular-cli: 1.0.0-beta.21
node: 6.4.0
os: win32 x64

angular-cli: 1.0.0-beta.22-1
node: 6.3.1
os: win32 x64

thx @teledemic, your solution work for me.

@Brocco can you have a look? It seems https://github.com/angular/angular-cli/issues/2822 broke this for older project configs.

This seems to be working fine in master

Also got this error. Tried several things already :)

"viewEncapsulation": "Emulated",
"changeDetection": "Default",

dit the fix

Closing this as fixed.

Change .angular-cli.json like this, working on 1.0.0

  "defaults": {
    "styleExt": "css",
    "component": {
      "viewEncapsulation": "Emulated",
      "changeDetection": "Default"
    }
  }

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