简体   繁体   中英

Angular Material (v8) module import errors

I'm having some annoying issues with the new version of Angular Material. I just upgraded from 7.xx to 8.1 for Material (and 7.xx to 8.1 for Angular), but in my module imports, I'm getting errors in WebStorm. Not sure if this is related to WebStorm, Angular, or some TS configuration and was wondering if anyone had any ideas.

This is occurring in every module where I import Material modules and for any Material module. It does NOT occur for component imports, only the module imports.

ng build --prod , ng serve --prod , and ng serve all work fine, but my editor still seems to complain.

Things I've already tried which have not worked:

  • Delete node_modules and reinstall
  • Import from @angular/material instead of the specific package (basically revert back to the way it was but keep Material at version 8).

EDIT

Per Morphyish's comment, I did a Code -> Inspect code... on my entire project.

Almost everywhere I import a module from angular is broken. For example, I'm using the @angular/flex-layout so all of my fxFlex attributes are giving me "unknown HTML tag" errors. Even the ReactiveFormsModule is saying it's an invalid imported symbol. The project ng serve s and ng build s correctly, so I don't know what's going on.

在此处输入图片说明

Webstorm, and all Intellij IDEs really, can be a bit slow to parse all your files and update the errors and auto-completion. Give it a bit of time and it should be fine again. Sometimes restarting your IDE can help if it's really an issue but it shouldn't affect your project.

If you think you might have an issue with your actual files, you can always try to make sure the folder/file are actually in your node_modules folder.

So, sometimes you just need to turn it off then on again. Morphyish was right, my IDE was drunk. I created a new project and copy/pasted all the files from my current project into it and ran Code -> Inspect Code... again. None of the errors from the original issue showed up. So I'm accepting Morphyish's answer as correct because he helped a lot, but if at first you don't succeed --- nuke everything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM