1
votes

I just used npm install bootstrap@next on my project and got the following compile error. I'm new to angular.

Failed to compile.

./node_modules/ansi-html/index.js Module build failed: Error: ENOENT: no such file or directory, open 'D:\ projects\board\node_modules\ansi-html\index.js' @ (webpack)-dev-server/client/overlay.js 3:15-35 @ (webpack)-dev-server/client?http://localhost:4200 @ multi webpack-dev-server/client?http://localhost:4200 ./www/main.ts

when compiling with ng serve i get:

Error: Cannot find module 'ansi-styles'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:\Users\ssarfraz\git projects\board\node_modules\@angular\cli\node_modules\chalk\index.js:3:20)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
2
what do you mean by npm install bootstrap@next ? - SeleM

2 Answers

0
votes

You should use npm install --save bootstrap or npm install --save [email protected] instead. And don't forget to include Bootstrap to your .angular-cli.json:

"styles": [
   "../node_modules/bootstrap/dist/css/bootstrap.min.css",
   "styles.css"
],

And for the error:

Error: Cannot find module 'ansi-styles'

There is a solution here: https://stackoverflow.com/a/25884689/6053654

0
votes

remove all files from \node_modules.bin and run "npm install" command.