What are the steps to resolve the UglifyJs error stating 'Unexpected token operator'?

When running the following command in my Angular app:

> ng build --prod --aot --env=staging

I encounter this error message:

ERROR in vendor.0625f773941bc83e6748.bundle.js from UglifyJs
Unexpected token operator «*», expected punc «(» [vendor.0625f773941bc83e6748.bundle.js:69512,51]

The issue seems to be related to a npm package called web-request, which I recently installed.

Within the npm-installed index.js file, there are functions like the one shown below:

function get(uri, options) {
    return __awaiter(this, void 0, void 0, function* () { return yield create(uri, Object.assign({}, options, { method: 'GET' })).response; });
}

It appears that Uglify does not support the function* syntax. Since the index.js file is not part of the source code of the npm package, how can I resolve this error?

Here is the content of my tsconfig.json file:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

Answer №1

To fully utilize Angular CLI 1.5, make sure to update your tsconfig.json file and set the target to "es6". This feature may only be compatible with ES6 syntax.

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

Is there a way to configure webpack to compress and merge SCSS and JavaScript files similar to how CodeKit does?

I've been struggling to transition from using Codekit v1.9.3 to webpack. My initial plan was to switch to Grunt and Gulp, but then I discovered webpack which seemed really interesting. Unfortunately, I'm having trouble getting it set up correctly ...

The ongoing ESLint conundrum: Balancing between "Unused variable" and "Unknown type" errors when utilizing imports for type annotations

I've encountered a linting issue and I need some guidance on how to resolve it. Here's the scenario - when running $ yarn lint -v yarn run v1.22.4 $ eslint . -v v6.8.0 With plugins vue and @typescript-eslint, I have the following code in a .ts ...

Ways to display an error message in Angular 8 when entering anything other than numbers in a text box

In my Angular 8 application, I have a text box that only allows the user to type numbers. If they try to type an alphabet or special character, it should display an error message below the text box. The error message should disappear once the user starts ...

Out of the blue, Angular has inexplicably ceased to function in development, production, and local environments, despite successfully

TypeError: n is not iterable TypeError: n is not iterable I am currently working on an Angular and Node.js project hosted on Heroku. Everything was running smoothly until recently when I encountered an error after successfully building Angular. Upon loadi ...

Guide on accessing and manipulating local files using an Angular application

For my Angular 7 web app project, I'm looking to allow users to complete surveys and submit their responses. Since I don't have a database set up yet, I thought of storing the results in a local json file for now. Unfortunately, I'm facing d ...

Error: The property 'case sensitive routing' cannot be accessed because it is undefined

Task at hand: Running ExpressJS port using Node.js, nodemon, and lib. Operating System: Windows 10 Home x64 Node.JS Version: Lts The Challenge: Getting the ExpressJS port to run successfully. Current Issue: Encountering an internal file error, potentiall ...

What is the most effective way to share data among components in React?

I recently delved into learning about react and find myself puzzled on how to pass data between two components. Presently, I have set up 2 functions in the following manner: First, there's topbar.tsx which displays information for the top bar, inclu ...

Utilize the Phoenix framework to run an NPM script within a specific subdirectory

I have a Phoenix app with a React frontend located in the assets/ directory. The frontend has its own package.json file, and I want to run aliased NPM scripts from the Phoenix app's mix.exs file. I tried using Elixir's System.cmd(), but it doesn& ...

How should one go about publishing an npm package developed using Browserify in the package.json file?

I have a npm package that I developed using Browserify and I'm unsure about the correct way to structure the package.json. This package is a node server-client app (specifically an atom package), with the client side built on Browseriy. ./www/js/ind ...

Is there a way for WebStorm to display a catalog of bower packages for me?

Good day. Here is my configuration: OSX El Capitan 10.11.2 JetBrains WebStorm 11.0.2 Node.js 4.2.3 NPM version 2.14.7 Bower 1.7.0 The NPM prefix is set to ~/.npm-global My executable path is configured as: $PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbi ...

React Native: Encounter a build error due to an undefined issue when building the JavaScript

I successfully set up react native by running: expo init AwesomeProject Initially, everything was working smoothly until I decided to install a new NPM package. I managed to create three pages without any issues, but encountered warnings after installing ...

Tips for center-aligning layouts in Angular Material

I am struggling with the Angular Material flex layout, so I took this directly from the Angular Material website. Based on the documentation for layout container, items are arranged in a row with a max-height of 100% and max-width matching the width of th ...

Can Typescript classes be hoisted if I use two classes in my code?

Exploring Class Definitions Certain Rules to Comply With Ensuring that the class is defined in advance helps avoid errors. class Polygon { log() { console.log('i am polygon'); } } const p = new Polygon(); // Expected: no errors p.log(); U ...

Struggling to containerize an Angular application

Struggling to deploy my Angular application as a docker image on Azure, I have hit a roadblock. Following the steps outlined in a video tutorial at https://learn.microsoft.com/en-us/azure/developer/javascript/tutorial-vscode-docker-node-01?tabs=bash did no ...

Nested router-outlets in Angular are not functioning properly for routing

I'm currently facing a challenge with Angular routing in a scenario that involves nested router-outlets. The objective is to have an application-wide banner at the top, followed by a dashboard navigation component that has its own router-outlet for di ...

"Learn how to utilize array values in TypeScript to easily display them using NgFor in HTML

Looking for a solution: <select (change)="getYear(year)"> <option value="year" *ngFor="let var of array; let i = index" {{year.year}} </option> </select> Is there a way to configure the typescript code so that I can dynamica ...

Utilizing Vue 3 props validation in conjunction with the power of Typescript

Looking to customize a Link component using Nuxt, Typescript, and the composition-api. The prop target can accept specific values as outlined below. I'm curious if using a custom validator function to check prop types at runtime adds value when compar ...

Converting Antdesign's Datepicker to Typescript

I'm having trouble figuring out how to properly annotate the dateObj parameter in the handleDateChange function that I've created. App.tsx import { useState } from 'react'; import logo from './logo.svg'; ...

Launch a designated window upon typing "npm start" into the terminal

Is it possible, instead of opening "localhost:3000" when running "npm start", to have the browser open "localhost:3000/param=1"? I'm looking for a solution that will work not only on my own PC but also when someone else installs my react app. Is there ...

An error has occurred: Type 'x' is not compatible with type 'x' (during Vercel deployment)

I encountered an issue during Vercel deployment which displays the following error message: - Type error: Type ' ({ params }: DashboardPageProps) = Promise' is not compatible with type 'FC<.DashboardPageProps>' Type 'Promise ...