简体   繁体   English

找不到本地“打字稿”包。“@ ngtools / webpack”包Angular 2

[英]Could not find local “typescript” package.The “@ngtools/webpack” package Angular 2

I searched here, Angular 2, @ngtools/webpack, AOT , but does not worked for me. 我在这里搜索了Angular 2,@ ngtools / webpack,AOT ,但不适合我。 I ran the npm install command. 我运行了npm install命令。 What i'm doing is that i'm creating a new Angular 2 project. 我正在做的是我正在创建一个新的Angular 2项目。 and while I run ng serve --open then I got the below error. 当我运行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' 找不到本地的“typescript”包。“@ ngtools / webpack”包需要安装本地“typescript@^2.0.2”包。错误:找不到模块'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`

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 “@ ngtools / webpack”包需要安装本地“typescript@^2.0.2”包

So webpack needs typescript and you just have to install it. 所以webpack需要打字稿,你只需要安装它。

npm install typescript@latest --save-dev

Yea this error also comes up when you upgrade "@angular/cli". 是的,当您升级“@ 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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