Angular2 - error in long-stack-trace-zone.js at line 106: Zone variable is not defined

Currently, I am utilizing the Angular2 starter with webpackjs AMD. While there are no build errors showing up, I encounter some issues when browsing (using npm server), resulting in the following errors:

What aspects might I be overlooking in my build configuration? What other factors should I review to ensure everything runs smoothly?

Thank you in advance.

//error one

In long-stack-trace-zone.js:106, an Uncaught ReferenceError occurs where Zone seems to be undefined. This issue is preventing specific functionalities from working as expected. The trace further indicates dependencies failing to load properly, impacting the application's performance.

//error two

The use of class decorators demands reflection metadata shim for proper integration. Missing out on this crucial element leads to potential failures and inconsistencies in functionality across the application. It is essential to address this requirement to maintain stability.

//package.json


{
  "name": "angular2",
  "version": "1.0.0",
  "description": "Angular 2",
   "scripts": {
    "build": "webpack",
    "start": "webpack-dev-server"
   },
"license": "ISC",
 "devDependencies": {
  "ts-loader": "^0.7.2",
  "tsd": "^0.6.5",
  "typescript": "^1.7.5",
  "webpack": "^1.12.11",
  "webpack-dev-server": "^1.14.1"
},
"dependencies": {
  "angular2": "^2.0.0-beta.11",
  "es6-promise": "^3.0.2",
  "es6-shim": "^0.33.13",
  "reflect-metadata": "^0.1.2",
  "rxjs": "^5.0.0-beta.0",
  "zone.js": "^0.6.5"
}
}

//ts.config

{
  "compilerOptions": {
    "target": "ES5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ],
  "filesGlob": [
    "typings/**/*.ts",
    "app/**/*.ts"
  ],
  "files": [
    "typings/angular2/angular2.d.ts",
    "typings/tsd.d.ts",
    "app/app.component.ts",
    "app/boot.ts",
    "app/vendor.ts"
  ],

  "compileOnSave": false,
  "buildOnSave": false,
  "atom": {
    "rewriteTsconfig": true
  }
}

//vendor.ts

// Polyfills

import 'es6-shim';
import 'es6-promise';
import 'zone.js/dist/long-stack-trace-zone';
import 'reflect-metadata';

Answer №1

To ensure proper functionality, it is crucial that you include the zone module in your polyfills. Furthermore, there is no need for the es6-promise module when using es6-shim, as it already contains similar functionality.

import 'es6-shim';
import 'zone.js/dist/zone'; // Don't forget this one
import 'zone.js/dist/long-stack-trace-zone';
import 'reflect-metadata';

Remember to upgrade to beta.12 and zone.js 0.6.6 as these versions address several bugs present in earlier releases related to the zone functionality.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Drizzle ORM retrieve unique string that is not a database column

I'm working with a SQL query that looks like this: SELECT * FROM ( SELECT 'car' AS type, model FROM car UNION SELECT 'truck' AS type, model FROM trucks ) vehicles; In Drizzle, I'm trying to replicate the 'car ...

Organize your Vue JS code by keeping all imports in separate files

Currently, I am delving into the realm of Vue.js and find myself faced with the task of loading numerous JSON files into my Vue project. Initially, I thought about directly importing each JSON file in the main file like so: //Index.vue <script> impo ...

Executing functions in Vue TypeScript during initialization, creation, or mounting stages

Just a few hours ago, I kicked off my Vue TypeScript project. I've successfully configured eslint and tslint rules to format the code as desired, which has left me quite pleased. Now, I'm curious about how to utilize the created/mounted lifecycl ...

The exclude option in Nest JS middleware does not prevent the middleware from running on excluded routes

I'm having an issue with excluding certain routes from the middleware. The .exclude option doesn't seem to be working as expected, as the middleware is still being applied to the excluded routes. Here is the code for the Middleware: https://i.st ...

Ionic 4's http.get.subscribe method fails to retain the retrieved value

I'm aware this might be a repeated question, but I haven't come across a straightforward answer yet, so here it goes. Below is the code snippet in question: fetchData() { let dataArray: Array<any> = [, , ,]; this.prepareDataReque ...

Get rid of the strange border on the material dialog

I am struggling with the Angular material 6 dialog component as it is displaying a strange border. I have attempted to remove it using the code below, without success. Interestingly, when I apply the style inline in the browser, it works fine. Any suggesti ...

Why am I struggling to show the success message on my basic CRM Angular web application?

I'm facing an issue in my Basic Angular app where the success message is not being displayed even after writing the correct code. 1)app.component.html <h1 class="c1">{{title}}</h1> <div *ngIf="success_msg;" style=&q ...

Issue with Typescript: For in loop not identifying object properties

Currently, I am utilizing a loop with for in to iterate through a list of Meeting objects named allMeetings. Inside this loop, I am populating another list called allEvents, where non-Meeting objects will be stored. However, when attempting to access the p ...

Is there Polyfill Compatibility for Custom Elements in Angular 9?

When it comes to polyfilling support for custom elements created with Angular, there are various recommendations available. This demo demonstrates that adding the following polyfill in polyfills.ts works: import '@webcomponents/webcomponentsjs/custo ...

TypeScript: defining a custom type with a collection of properties following a consistent pattern

I am looking for a way to create a type that can accommodate any number of properties following a predefined pattern, like so: type Values = { id: number; id1?: number; id2?: number; id3?: number; // ... somethingElse: string; anotherOne: num ...

"Upload a video file and use JavaScript to extract and save the first frame as an image

I have a webpage where users can upload a video file, and the page will generate a thumbnail based on a timestamp provided by the user. Currently, I am focusing on generating the thumbnail from the FIRST frame of the video. Here is an example of my progr ...

Manipulating arrays and troubleshooting Typescript errors in Vue JS

I am attempting to compare the elements in one list (list A) with another list (list B), and if there is a match, I want to change a property/field of the corresponding items in list B to a boolean value. Below is the code snippet: export default defineCo ...

Every time I try to run my Angular app, it crashes. I've already tried reinstalling Node and rebooting

After attempting to relocate an angular project into a different folder yesterday, I encountered issues when trying to start the app using ng serve. Interestingly, creating a new project and running ng serve resulted in the same error. Both projects were ...

Sending a DOM element to a directive without using a template reference variable

Is there a way to pass a DOM node to a function in a directive for adding a class without using a reference variable? Check out this functioning plunker for the current implementation: https://plnkr.co/edit/9gBG0MXxeqlGB3eTau1T?p=preview export class App ...

Is it possible for Angular 2 JWT to have an unauthenticatedRedirector feature?

Having transitioned from Angular 1 where JWT tokens were used for user authentication, I had the following code: .config(function Config($httpProvider, jwtOptionsProvider) { // Interceptor to add token to every $http request jwtOptionsProv ...

What is the best way to arrange map elements in a React application?

I am trying to implement filter buttons for low to high rates and high to low rates, but I am having trouble figuring it out. How can I apply the filter to display the data accordingly? The data that needs to be filtered is stored in rate.retail_rate. ty ...

How to build a login page with a static header and footer using Angular2

For my latest project, I am currently in the process of developing an application using Angular2 and eclipse Neon. Utilizing angular-cli for this app, I am now focused on creating the login page. Within the app.component.html file, you will find the follow ...

The TypeScript Promise error codes TS2304 and TS2529 are causing confusion among

I came across the code below: function asyncTask(): Promise<string> { return new Promise<string>(resolve => resolve); } This code resulted in the following error: TS2304: cannot find name 'Promise' To address this issue, ...

What is causing the error even though @angular/core is present in the node_modules folder?

I recently downloaded a sample project from angular.io by following this link: https://angular.io/generated/zips/cli-quickstart/cli-quickstart.zip After downloading, I proceeded to run npm install in the root folder just like in the tutorial found here: ...

Creating a Typescript union array that utilizes a string enum for defining key names

Can we shorten this statement using string enum to restrict keys: Array<{ [enum.example1]: Example } | { [enum.example2]: Example } | ...> // or equivalent ({ [enum.example1]: Example } | { [enum.example2]: Example } | ...)[]; We can make it more c ...