Angular-cli: "error TS2304: Cannot find name "ViewEncapsulation'" when I run 'ng generate component '.

Created on 6 Nov 2017  路  6Comments  路  Source: angular/angular-cli

This seems to be an infrequent problem for you that keeps popping up. See #4832

Bug Report or Feature Request (mark with an x)

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

Versions.


Windows 7

Angular CLI: 1.5.0
Node: 6.11.3
OS: win32 x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.1
typescript: 2.4.2
webpack: 3.8.1

Repro steps.

I started your Tour of heroes tutorial. Step 3 had me run ng generate component heroes. This caused the compile to fail with error TS2304: Cannot find name 'ViewEncapsulation'. The tutorial didn't expect this line at the bottom of the component definition.
encapsulation: ViewEncapsulation.None
I had to manually add - import { ViewEncapsulation } from '@angular/core';
to fix the error.

The log given by the failure.


error TS2304: Cannot find name 'ViewEncapsulation'

Desired functionality.

Mention any other details that might be useful.

Most helpful comment

I know, it is in the repro steps. I'm just saying that it should generate files that compile.

All 6 comments

import { ViewEncapsulation } from '@angular/core'
this will fix the problem.

I know, it is in the repro steps. I'm just saying that it should generate files that compile.

Same here posted yesterday #8374

Dup of #8374.

i got this error in my component and i don't know how to solve it
ERROR in src/app/metronic/metronic.component.ts(13,5): error TS2304: Cannot find name '$'.

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

Related issues

gotschmarcel picture gotschmarcel  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

hareeshav picture hareeshav  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments