Joshua Kemmerer
Joshua Kemmerer

Reputation: 1673

How to fix 'Unexpected token operator' error from UglifyJs?

In my Angular app, I run this command:

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

and that outputs:

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

I have narrowed the error down to a npm package I recently installed, web-request.

In the npm-installed index.js file, there are a few functions like the following:

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

And Uglify must not like the function*. Given that this index.js isn't a part of the source code of the npm package, how can I fix this error?

Here's 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"
    ]
  }
}

Upvotes: 1

Views: 1440

Answers (1)

Install angular cli 1.5 and change your tsconfig.json target to "es6", perhaps this is a feature only supported by es6?

Upvotes: 1

Related Questions