Module not found: Error: Can't resolve 'classlist.js' in angular cli 6.1.3

Viewed 6255

I am getting following while running ng buid --watch command in terminal,

ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'classlist.js' in 'E:\eclipse_dis_workspace\tourdubai\UI\src'

following version used,

Angular CLI: 6.1.3
Node: 8.11.3
OS: win32 x64
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.3
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.3
@angular-devkit/schematics        0.7.3
@angular/cli                      6.1.3
@ngtools/webpack                  6.1.5
@schematics/angular               0.7.3
@schematics/update                0.7.3
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2

i did all the setup configuration, like npm i.

thanks in advance.

2 Answers

remove the current package

npm uninstall classlist.js --save

then run

npm cache verify

run

npm install classlist.js --save-exact

There are different options;

I would suggest to add

(window as any).global = window; 

in polyfills.ts;

if that doesn´t work, then add

<script>
var global = global || window;
var Buffer = Buffer || [];
var process = process || {
env: { DEBUG: undefined },
version: []
};
</script>

to Index.html; either of them should work.

Related