Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

334
Views
Angular 4, Unexpected token error during ng build --prod

I am working on an Angular 4 application that utilizes angular-cli and webpack2.

I can successfully build the project with ng build

However, when I run ng build --prod the following error is thrown:

ERROR in main.50d83f3f70f7e607ec7a.bundle.js from UglifyJs Unexpected token: name (FilterPipe) [main.50d83f3f70f7e607ec7a.bundle.js:7,6]

I don't understand what is wrong.

Here is my filter.pipe.ts file:

import {Pipe, PipeTransform } from '@angular/core';

@Pipe({ 
    name: 'filter'
})

export class FilterPipe implements PipeTransform {
    transform(items: any[], field : string, value : string): any[] { 
        if (!items) return [];  
        return items.filter(it => it[field] == value);
    }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This happens because Uglify doesnt support es6 syntax yet.

https://github.com/angular/angular-cli/issues/1663

Modify tsconfig.json to check fr sure that "target": "es5", is there Example :

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!