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.

Angular 5: uncaught ReferenceError: ViewEncapsulation is not defined

See original GitHub issue

Bug Report

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

Versions.

Angular CLI: 1.5.0
Node: 6.11.5
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.0
@angular/material: 5.0.0-rc0
@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.

ng generate component header

TS code:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css'],
  encapsulation: ViewEncapsulation.None
})
export class HeaderComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

The log given by the failure.

header.component.ts:7 Uncaught ReferenceError: ViewEncapsulation is not defined
    at eval (header.component.ts:7)
    at eval (header.component.ts:16)
    at Object.../../../../../src/app/header/header.component.ts (main.bundle.js:58)
    at __webpack_require__ (inline.bundle.js:55)
    at eval (app.module.ts:5)
    at Object.../../../../../src/app/app.module.ts (main.bundle.js:36)
    at __webpack_require__ (inline.bundle.js:55)
    at eval (main.ts:4)
    at Object.../../../../../src/main.ts (main.bundle.js:74)
    at __webpack_require__ (inline.bundle.js:55)

Desired functionality.

Fails to render in browser with console error

Mention any other details that might be useful.

Mac OS

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:15
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
sgperezcortezcommented, Nov 8, 2017

This is the official solution: https://angular.io/api/core/ViewEncapsulation

npm Package | @angular/core import { ViewEncapsulation } from ‘@angular/core’;

2reactions
isaklafleurcommented, Nov 8, 2017

Looks like the ViewEncapsulation are now imported after upgrading to Angular 5.0.1.

import { Component, OnInit, ViewEncapsulation } from "@angular/core";

@Component({
  selector: "app-my-foo",
  templateUrl: "./my-foo.component.html",
  styleUrls: ["./my-foo.component.css"],
  encapsulation: ViewEncapsulation.None,
})
export class MyFooComponent implements OnInit {
  constructor() {}

  ngOnInit() {}
}

I would also thank the Angular team which are working really hard on this amazing product! And please people, who complains… Stop doing it. You are not paying for this products, so if there are any bugs, instead of complaining, you should try to help to fix the bugs! 😉

Angular CLI: 1.5.0
Node: 8.9.0
OS: darwin x64
Angular: 5.0.1
... 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.2
typescript: 2.4.2
webpack: 3.8.1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "viewEncapsulation is not defined" when adding ...
D:\GIT\PartnerOrders2\node_modules\angular-cli\blueprints\component\files__path____name__.component.ts),. Anyone have an idea how to solve?
Read more >
Uncaught ReferenceError: Angular is not defined
In this article, we will see the “Uncaught ReferenceError: Angular is not defined”, along with knowing a possible way to resolve it.
Read more >
View encapsulation - Angular
In Angular, a component's styles can be encapsulated within the component's host element so that they don't affect the rest of the application....
Read more >
process is not defined angular - You.com | The AI Search ...
Angular 11: Uncaught ReferenceError: process is not defined ... For webpack 5, you can reference process/browser from the appropriate plugins part of ...
Read more >
Let • Angular - codecraft.tv
Copy Uncaught ReferenceError: a is not defined(…) This is because the a variable is declared inside a function and is therefore only visible...
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