question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

15reactions
parkzonecommented, Nov 6, 2017

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

11reactions
rowanD72commented, Nov 6, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular and Typescript: Can't find names - Error: cannot find ...
ts(1,37): Error TS2304: Cannot find name 'Zone'. This is the code: import 'reflect-metadata'; import {bootstrap, Component ...
Read more >
ViewEncapsulation - Angular
Emulates a native Shadow DOM encapsulation behavior by adding a specific attribute to the component's host element and applying the same attribute to...
Read more >
ng generate - Angular
Generates an application shell for running a server-side version of an app. ... The view encapsulation strategy to use in the new component....
Read more >
ng serve - Angular
Option Description Value Type Default Value ‑‑hmr Enable hot module replacement. boolean false ‑‑host Host to listen on. string localhost ‑‑open Opens the url in default...
Read more >
Setting up the local environment and workspace - Angular
You use the Angular CLI to create projects, generate application and library ... Run the CLI command ng new and provide the name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found