【问题标题】:Could not find local "typescript" package.The "@ngtools/webpack" package Angular 2找不到本地“typescript”包。“@ngtools/webpack”包Angular 2
【发布时间】:2018-03-01 14:51:40
【问题描述】:

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

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

我们将不胜感激。

下面是堆栈跟踪:

`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`

【问题讨论】:

  • npm install typescript@latest --save-dev
  • 谢谢@gyc!它工作:)

标签: angular typescript


【解决方案1】:

为了在 cmets 部分没有答案,这里的错误是不言自明的:

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

所以 webpack 需要 typescript,你只需要安装它。

npm install typescript@latest --save-dev

【讨论】:

  • 当然应该帮助像我这样的人。
  • 它根本没有帮助
【解决方案2】:

是的,当您升级“@angular/cli”时也会出现此错误。 除了你不能仅仅通过再次安装 typescript 来修复它。

这就是我修复它的方法:

npm uninstall -g @angular/cli
npm uninstall --save-dev @angular/cli 
npm install -g @angular/cli@latest
npm install --save-dev @angular/cli@latest

【讨论】:

    猜你喜欢
    • 2017-07-27
    • 1970-01-01
    • 1970-01-01
    • 2018-04-22
    • 1970-01-01
    • 2016-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多