vs code cannot find module '@angular/core' or any other modules

前端 未结 30 1121
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 03:10

my project was generated with [Angular CLI] version 1.2.6.

I can compile the project and it works fine, but I always get error in vs code telling me cannot find mo

相关标签:
30条回答
  • 2020-12-23 03:15

    If we get this type of error just use the command:

     npm i @anglar/core,
     npm i @angular/common,
     npm i @angular/http,
     npm i @angular/router
    

    After installing this also showing error just remove few words then again add that word its working.

    0 讨论(0)
  • 2020-12-23 03:18

    You need to install it manually.

    $ npm i @angular/core -s
    
    0 讨论(0)
  • 2020-12-23 03:20

    In the VSCode status bar, it must be showing typescript version - like this

    Clicking on that version number will show you this, different versions available.

    If you are using the VSCode version then switching to Workspace version solves the problem if it is VScode issue rather than your tsconfig.json (I am already using that one, so not highlighted)

    0 讨论(0)
  • 2020-12-23 03:21

    In my case it was a mispelling of the import line. Check that you have spelt the @angular/core part properly if typing it out manually.

    import { Component } from '@angular/core';

    0 讨论(0)
  • 2020-12-23 03:22

    Delete Node Modules folder from project folder.Run below command

    npm cache clean --force npm install

    It should work.

    0 讨论(0)
  • 2020-12-23 03:22

    Executing the following two commands solves the problem for me:

    npm install -g @angular/cli
    ng update --all --force
    
    0 讨论(0)
提交回复
热议问题