Angular: HttpClientModule import error (could not be resolved to an NgModule class)

后端 未结 4 1838
不思量自难忘°
不思量自难忘° 2021-02-02 10:33

I was trying to build a simple app with crud on fake json server

but i can\'t import HttpClientModule

Here is error message from VS Code

相关标签:
4条回答
  • 2021-02-02 10:45

    I had the same problem, I just run the following command and it worked after without any error.

    npm cache verify
    

    If it does not, try manually deleting the node_modules folder and reinstalling the modules with npm install.

    rm -rf node_modules
    npm install
    

    On npm > 6, you can also run npm ci, which also deletes the node_modules folder and reinstall packages after.

    Edit As other answers suggested, you may need to restartng serve if the above steps do not work (but they normally do)

    0 讨论(0)
  • 2021-02-02 10:45

    I had the same issue. So, I manually deleted node_modules and then npm install. It solved as this issue was because of the corrupt dependencies.

    0 讨论(0)
  • 2021-02-02 10:50

    just stop ng serve before adding new package, after adding new package restart ng serve. This will solve this issue.

    0 讨论(0)
  • 2021-02-02 11:03

    First Stop ng serve and run these commands...

    npm cache verify
    rm -rf node_modules
    npm install
    

    After the installation build & run your project using the commands

    ng build
    ng serve
    

    It works for me and solve the issue...

    0 讨论(0)
提交回复
热议问题