Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular4.x Module not found: Error: Can't resolve 'classlist.js'

When I remove comment part in polyfills.ts for polyfills to load page in Internet Explore

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
 import 'core-js/es6/symbol';
 import 'core-js/es6/object';
 import 'core-js/es6/function';
 import 'core-js/es6/parse-int';
 import 'core-js/es6/parse-float';
 import 'core-js/es6/number';
 import 'core-js/es6/math';
 import 'core-js/es6/string';
 import 'core-js/es6/date';
 import 'core-js/es6/array';
 import 'core-js/es6/regexp';
 import 'core-js/es6/map';
 import 'core-js/es6/weak-map';
 import 'core-js/es6/set';
 import 'reflect-metadata';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
 import 'classlist.js';  // Run `npm install --save classlist.js`.

/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';


/**
 * Required to support Web Animations `@angular/animation`.
 * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
 **/
 import 'web-animations-js';  // Run `npm install --save web-animations-js`.

But if we do build using angular cli. it throws error in console I did run this command in project "npm install --save classlist.js"

Module not found: Error: Can't resolve 'classlist.js' in src
 @ ./src/polyfills.ts 36:0-22
 @ multi ./src/polyfills.ts

Please suggest solution

like image 743
MayureshP Avatar asked Feb 08 '18 15:02

MayureshP


2 Answers

remove the current package,

npm uninstall classlist.js --save

then run

npm cache verify

afterwards run

npm install classlist.js --save-exact
like image 167
Daniel Netzer Avatar answered Nov 11 '22 01:11

Daniel Netzer


You're importing a polyfill that is not included by default. You have to install it as a dependency first. How to do that is in a comment on the same line that imports it:

// Run `npm install --save classlist.js`.

The same goes for the web-animations-js polyfill if you haven't done so already.

like image 39
Manduro Avatar answered Nov 11 '22 00:11

Manduro