Skip to content

"error TS2304: Cannot find name "ViewEncapsulation'" when I run 'ng generate component '. #8376

@parkzone

Description

@parkzone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions