5

I searched here, Angular 2, @ngtools/webpack, AOT, but does not worked for me. I ran the npm install command. What i'm doing is that i'm creating a new Angular 2 project. and while I run ng serve --open then I got the below error.

could not find local "typescript" package.The "@ngtools/webpack" package requires a local "typescript@^2.0.2" package to be installed.Error: Cannot find module 'typescript'

Any help will be highly appreciated.

Below is the stacktrace:

`C:\Users\jang\Desktop\kendoGrid>ng serve --open
Could not find local "typescript" package.The "@ngtools/webpack" package requires a local "typescript@^2.0.2" package to be installed.Error: Cannot find module 'typescript'
Error: Could not find local "typescript" package.The "@ngtools/webpack" package requires a local "typescript@^2.0.2" package to be installed.Error: Cannot find module 'typescript'
    at Object.<anonymous> (C:\Users\jang\Desktop\kendoGrid\node_modules\@ngtools\webpack\src\index.js:18:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\jang\Desktop\kendoGrid\node_modules\@angular\cli\models\webpack-config.js:3:19)
    at Module._compile (module.js:570:32)

C:\Users\jang\Desktop\kendoGrid>ng version`
Jabongg
  • 2,099
  • 2
  • 15
  • 32

2 Answers2

11

For the sake of not having answers in the comments section, here the error is self explanatory:

The "@ngtools/webpack" package requires a local "typescript@^2.0.2" package to be installed

So webpack needs typescript and you just have to install it.

npm install typescript@latest --save-dev
gyc
  • 4,300
  • 5
  • 32
  • 54
0

Yea this error also comes up when you upgrade "@angular/cli". Except that you can't fix it by merely installing typescript again.

This is how I fixed it:

npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli 
npm install -g @angular/cli@latest
npm install --save-dev @angular/cli@latest
Pang
  • 9,564
  • 146
  • 81
  • 122
Ryan
  • 11
  • 1