Error: Cannot find module 'ansi-styles' in AngularJS with Yeoman generator

你离开我真会死。 提交于 2019-12-24 05:49:17

问题


My code was working previously before, but seems to have stopped working. I tried yo angular:route api but this error was returned:

Error: Cannot find module 'ansi-styles'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-angular/node_modules/chalk/index.js:2:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

I have added all the dependencies required to my package file, update npm (which is now on 2.0.0alpha), all npm packages, and ran npm install. The site still works when I grunt serve.


回答1:


(The O.P.):

I found the reason I got the error. I had to change the npm root folder and reinstalled my packages in the default folder and now it works.




回答2:


Just needed to run npm install here. Was a fresh clone out of Git.



来源:https://stackoverflow.com/questions/25222519/error-cannot-find-module-ansi-styles-in-angularjs-with-yeoman-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!