2018年1月15日
拉了别的小伙伴写的最新的代码下来,结果本地npm install之后用ng serve启动时一直报下面的错误:
ERROR in ./node_modules/css-loader?{"sourceMap":false,"import":false}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./src/styles.cssModule build failed: Error: Can't resolve '~@angular/material/prebuilt-themes/indigo-pink.css' in 'G:workspacefbhfbh-web-adminsrc' at onError (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibResolver.js:61:15) at loggingCallbackWrapper (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibcreateInnerCallback.js:31:19) at runAfter (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibResolver.js:158:4) at innerCallback (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibResolver.js:146:3) at loggingCallbackWrapper (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibcreateInnerCallback.js:31:19) at next (G:workspacefbhfbh-web-admin ode_modules apablelibTapable.js:252:11) at G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibUnsafeCachePlugin.js:40:4 at loggingCallbackWrapper (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibcreateInnerCallback.js:31:19) at runAfter (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibResolver.js:158:4) at innerCallback (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibResolver.js:146:3) at loggingCallbackWrapper (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibcreateInnerCallback.js:31:19) at next (G:workspacefbhfbh-web-admin ode_modules apablelibTapable.js:252:11) at innerCallback (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibResolver.js:144:11) at loggingCallbackWrapper (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibcreateInnerCallback.js:31:19) at next (G:workspacefbhfbh-web-admin ode_modules apablelibTapable.js:249:35) at resolver.doResolve.createInnerCallback (G:workspacefbhfbh-web-admin ode_modulesenhanced-resolvelibDescriptionFilePlugin.js:44:6) @ ./src/styles.css 4:14-138 @ multi ./src/styles.css ./src/assets/table.scssERROR in node_modules/@angular/flex-layout/media-query/breakpoints/break-points.d.ts(8,10): error TS2305: Module '"G:/workspace/fbh/fbh-web-admin/node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.
在网上查了,主要就是一个css文件被引用时候出现解析的问题,但是在添加了node-sass,css-loader等之后也还是不行。
尝试了重新安装node-module文件,但是都不行。
最后只能用大招,按照angular GitHub的步骤,卸载了angular-cli然后重新全局安装,
安装的时候,@angular/cli@1.5.0,版本号要选择和package.json文件中的一致。
还是剩下这么个错:
ERROR in node_modules/@angular/flex-layout/media-query/breakpoints/break-points.d.ts(8,10): error TS2305: Module '"G:/workspace/fbh/fbh-web-admin/node_modules/@angular/core/core"' has no exported member 'OpaqueToken'.
项目里面是使用 @angular/flex-layout 进行布局的,所以再尝试重新安装flex-layout
npm install @angular/flex-layout@latest --save
终于正常了, o(╥﹏╥)o。