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:\workspace\fbh\fbh-web-admin\src' at onError (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\Resolver.js:61:15) at loggingCallbackWrapper (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at runAfter (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\Resolver.js:158:4) at innerCallback (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\Resolver.js:146:3) at loggingCallbackWrapper (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at next (G:\workspace\fbh\fbh-web-admin\node_modules\tapable\lib\Tapable.js:252:11) at G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:40:4 at loggingCallbackWrapper (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at runAfter (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\Resolver.js:158:4) at innerCallback (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\Resolver.js:146:3) at loggingCallbackWrapper (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at next (G:\workspace\fbh\fbh-web-admin\node_modules\tapable\lib\Tapable.js:252:11) at innerCallback (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\Resolver.js:144:11) at loggingCallbackWrapper (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\createInnerCallback.js:31:19) at next (G:\workspace\fbh\fbh-web-admin\node_modules\tapable\lib\Tapable.js:249:35) at resolver.doResolve.createInnerCallback (G:\workspace\fbh\fbh-web-admin\node_modules\enhanced-resolve\lib\DescriptionFilePlugin.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。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM