Skip to content

Angular 8.2.13 Build : An unhandled exception occurred: Unexpected token: punc ()) #465

@imtase

Description

@imtase

An unhandled exception occurred: Unexpected token: punc ()) when try to build for production in Angular with the command

ng build --prod --aot=true --commonChunk=true --optimization=true --vendorChunk=true --base-href=./ 

Screenshot from 2019-11-12 15-46-39

How to reproduce

1 - create a new angular app
2 - install the package npm install steem --save
3 - in app.component.ts

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

import * as steem from 'steem';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'steembug';

  constructor(){
    steem.api.getAccounts(['ned', 'dan'], function(err, result) {
      console.log(err, result);
    });    
  }
}

4 - to solve the error of Global in polyfills.ts add

(window as any).global = window;

5 - to solve the error of Buffer edit 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js' and modify node: false by

node: {crypto: true, stream: true}

Environment:

Screenshot from 2019-11-12 15-36-05

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions