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

问题描述 投票:5回答:2

我在这里搜索,Angular 2, @ngtools/webpack, AOT,但不适合我。我跑了npm install命令。我正在做的是我正在创建一个新的Angular 2项目。当我运行ng serve --open然后我得到以下错误。

找不到本地的“typescript”包。“@ ngtools / webpack”包需要安装本地“typescript@^2.0.2”包。错误:找不到模块'typescript'

任何帮助将受到高度赞赏。

下面是堆栈跟踪:

`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`
angular typescript
2个回答
10
投票

为了在评论部分没有答案,这里的错误是自解释的:

“@ ngtools / webpack”包需要安装本地“typescript@^2.0.2”包

所以webpack需要打字稿,你只需要安装它。

npm install typescript@latest --save-dev

0
投票

是的,当您升级“@ angular / cli”时,也会出现此错误。除了你不能通过再次安装打字稿来解决它。

这就是我修复它的方法:

npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli 
npm install -g @angular/cli@latest
npm install --save-dev @angular/cli@latest
© www.soinside.com 2019 - 2024. All rights reserved.