• Angular项目在npm install之后用ng serve启动发生错误


    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。

  • 相关阅读:
    k8s是什么
    jmeter性能测试的策略
    面试的灵魂拷问:你最大的缺点是什么?
    面试的灵魂拷问:你做过的最令你自豪的事情是什么?
    面试的灵魂拷问:你犯过的最大的失误是什么?
    5-django rest framework,搭建api,这是最重要的章节
    4-restfulapi的介绍,vue代码结构
    组合恒等式证明——「Zeilberger 老爷子的 T 恤上写了啥?」
    「NOI2020」 美食家 【矩阵快速幂】
    [CEOI2014] The Wall【最短路】
  • 原文地址:https://www.cnblogs.com/viola-sh/p/14254542.html
Copyright © 2020-2023  润新知