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

拉了别的小伙伴写的最新的代码下来,结果本地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.css Module 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.scss 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'.

在网上查了,主要就是一个css文件被引用时候出现解析的问题,但是在添加了node-sass,css-loader等之后也还是不行。

尝试了重新安装node-module文件,但是都不行。

最后只能用大招,按照angular GitHub的步骤,卸载了angular-cli然后重新全局安装,

安装的时候,@angular/[email protected],版本号要选择和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。

你可能感兴趣的:(Angular项目在npm install之后用ng serve启动发生错误)