How to fix Cannot find module 'typescript' in Angular 4?

后端 未结 11 636
遥遥无期
遥遥无期 2020-12-09 07:40

I generated Angular 4 app 3 weeks ago using the @angular/cli. After 2 weeks, I tried to run it with the command line \"ng serve\" but I am prompted an error bel

相关标签:
11条回答
  • 2020-12-09 08:05

    Run 'npm install' it will install all necessary pkg .

    0 讨论(0)
  • 2020-12-09 08:06

    If you use yarn instead of npm, you can install typescript package for that workspace by running:

    yarn add typescript
    

    or you can install it globally by running:

    sudo yarn global add typescript
    

    to be available for any project.

    0 讨论(0)
  • 2020-12-09 08:07

    If you have cloned your project from git or somewhere then first, you should type npm install.

    0 讨论(0)
  • 2020-12-09 08:08

    I had a very similar problem after moving a working project to a new subdirectory on my file system. It turned out I had failed to move the file named .angular-cli.json to the subfolder along with everything else. After noticing that and moving the file into the subdirectory, all was back to normal.

    0 讨论(0)
  • 2020-12-09 08:11

    For me just running the below command is not enough (though a valid first step):

    npm install -g typescript

    The following command is what you need (I think deleting node_modules works too, but the below command is quicker)

    npm link typescript

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