3

I am facing some serious issues running my angular project after installing the 'woocommerce-api' package. The sequence of problems and the solutions I tried are:

Problem 1 (fixed): Can't resolve errors (crypto, fs, http, https, net, path, stream, tls, zlib) while building the project.

To solve this, I referred this page which resolved the errors and project was getting compiled successfully.

Problem 2 (fixed): Uncaught ReferenceError: global is not defined.

This was also fixed referring this link.

Ptoblem 3: Uncaught TypeError: Cannot read property 'prototype' of undefined (inherits_browser.js)

Thought I had referred this link but the solution doesn't seem to help me out. Also, I got to know what in the below code was causing all the problems:

import { Component } from '@angular/core';
import * as WC from 'woocommerce-api';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})


 export class AppComponent {
      title = 'tempPro1';
      woo: any;
      constructor() {
        //Below line 
        this.woo = WC({
          url: "***",
          consumerSecret: "***",
          consumerKey: "***"
    });
   }
 }

The initialization in the constructor to this.woo is causing the error. If that line is removed, the error for the undefined prototype goes off. I understand Woocommmerce-api would be having some dependency which I am not able to figure out. Any inputs?

Here is the actual error screenshot: Error

Abhishek
  • 539
  • 5
  • 25

0 Answers0