Error Angular 5 + NGX_Restangular + Webpack-dev-server

Issue

Using Angular 5 + NGX_Restangular + Webpack-dev-server

Angular 5
"ngx-restangular": "2.2.3"
"webpack": "4.5.0",
"webpack-dev-server": "3.1.3"

Success building application and starting web server = ng serve

Failure running application on web server using webpack after running ng eject

npm start 

npm start = ‘”start”: “webpack-dev-server –port=4200″‘

Chrome Console:

    core.js:1448 ERROR Error: Uncaught (in promise): TypeError: _.isArray is not a function
TypeError: _.isArray is not a function
    at RestangularFactory (ngx-restangular.config.js:11)
    at _callFactory (core.js:10916)
    at _createProviderInstance$1 (core.js:10868)
    at resolveNgModuleDep (core.js:10850)
    at _createClass (core.js:10895)
    at _createProviderInstance$1 (core.js:10865)
    at resolveNgModuleDep (core.js:10850)
    at NgModuleRef_.webpackJsonp../node_modules/@angular/core/esm5/core.js.NgModuleRef_.get (core.js:12087)
    at resolveNgModuleDep (core.js:10854)
    at NgModuleRef_.webpackJsonp../node_modules/@angular/core/esm5/core.js.NgModuleRef_.get (core.js:12087)
    at RestangularFactory (ngx-restangular.config.js:11)
    at _callFactory (core.js:10916)
    at _createProviderInstance$1 (core.js:10868)
    at resolveNgModuleDep (core.js:10850)
    at _createClass (core.js:10895)
    at _createProviderInstance$1 (core.js:10865)
    at resolveNgModuleDep (core.js:10850)
    at NgModuleRef_.webpackJsonp../node_modules/@angular/core/esm5/core.js.NgModuleRef_.get (core.js:12087)
    at resolveNgModuleDep (core.js:10854)
    at NgModuleRef_.webpackJsonp../node_modules/@angular/core/esm5/core.js.NgModuleRef_.get (core.js:12087)
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at zone.js:873
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4740)
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
    at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)

This only happens when I inject restangular and using webpack-dev-server.

import { Component, OnInit} from '@angular/core';
import { Restangular } from 'ngx-restangular';

@Component({
  selector: 'app-onenote-open',
  templateUrl: './onenote-open.component.html',
  styleUrls: ['./onenote-open.component.scss']
})
export class OnenoteOpenComponent implements OnInit {

  constructor(@Inject(Restangular) public xxx) { }

  ngOnInit() {
  }

}

Solution

There appears to be a problem with ngx-restangular 2.2.3 and ng ejects > webpack.config.js

Problem solved by using package.json > “ngx-restangular”: “2.3.0-beta.3”

Answered By – DeanB_Develop

Answer Checked By – Gilberto Lyons (AngularFixing Admin)

Leave a Reply

Your email address will not be published.