从 5 到 6 的角度迁移后无法构建 - 找不到模块“打字稿”
Posted
技术标签:
【中文标题】从 5 到 6 的角度迁移后无法构建 - 找不到模块“打字稿”【英文标题】:Can't build after angular migration from 5 to 6 - Cannot find module 'typescript' 【发布时间】:2018-11-24 03:19:34 【问题描述】:我正在将 Angular 应用程序从 5 迁移到 6。运行
ng update @angular/cli
和ng update @angular/core
但现在如果我运行 ng build
,我会收到此错误
Cannot find module 'typescript' from 'C:\..\App'
Error: Cannot find module 'typescript' from 'C:\..\App'
at Function.module.exports [as sync] (C:\..\App\MyApp\node_modules\resolve\lib\sync.js:42:15)
at resolveProjectModule (C:\..\App\MyApp\node_modules\@angular-devkit\build-angular\src\angular-cli-files\utilities\require-project-module.js:15:20)
at Object.requireProjectModule (C:\..\App\MyApp\node_modules\@angular-devkit\build-angular\src\angular-cli-files\utilities\require-project-module.js:20:20)
at BrowserBuilder.buildWebpackConfig (C:\..\App\MyApp\node_modules\@angular-devkit\build-angular\src\browser\index.js:103:52)
at Observable.rxjs_1.Observable.obs [as _subscribe] (C:\..\App\MyApp\node_modules\@angular-devkit\build-angular\src\browser\index.js:35:38)
at Observable._trySubscribe (C:\..\App\MyApp\node_modules\rxjs\internal\Observable.js:43:25)
at Observable.subscribe (C:\..\App\MyApp\node_modules\rxjs\internal\Observable.js:29:22)
at C:\..\App\MyApp\node_modules\rxjs\internal\util\subscribeTo.js:22:31
at Object.subscribeToResult (C:\..\App\MyApp\node_modules\rxjs\internal\util\subscribeToResult.js:7:45)
at MergeMapSubscriber._innerSub (C:\..\App\MyApp\node_modules\rxjs\internal\operators\mergeMap.js:75:38)
at MergeMapSubscriber._tryNext (C:\..\App\MyApp\node_modules\rxjs\internal\operators\mergeMap.js:72:14)
at MergeMapSubscriber._next (C:\..\App\MyApp\node_modules\rxjs\internal\operators\mergeMap.js:55:18)
at MergeMapSubscriber.Subscriber.next (C:\..\App\MyApp\node_modules\rxjs\internal\Subscriber.js:64:18)
at TapSubscriber._next (C:\..\App\MyApp\node_modules\rxjs\internal\operators\tap.js:62:26)
at TapSubscriber.Subscriber.next (C:\..\App\MyApp\node_modules\rxjs\internal\Subscriber.js:64:18)
at MergeMapSubscriber.notifyNext (C:\..\App\MyApp\node_modules\rxjs\internal\operators\mergeMap.js:84:26)
package.json 在 devDependencies 中包含"typescript": ">=2.7.0 <2.8.0"
清理 npm 缓存并重新安装所有软件包,但没有帮助。
有人遇到同样的问题吗?
【问题讨论】:
相关:***.com/questions/44611526/… 似乎不一样 .angular-cli.json 不再需要了。重新安装没有帮助 您是否按照update.angular.io 中的所有步骤操作? 是的。最后一步 - rxjs 迁移似乎不会影响这个问题。但我不确定 我也遇到了同样的问题,你有没有解决? 【参考方案1】:干净地重新安装打字稿
- npm uninstall -g typescript
- npm uninstall typescript
- npm install -g typescript
- npm install typescript@2.7.2
【讨论】:
以上是关于从 5 到 6 的角度迁移后无法构建 - 找不到模块“打字稿”的主要内容,如果未能解决你的问题,请参考以下文章
基本角度应用程序无法运行,错误模块构建失败:找不到模块../@angular-devkit/src/babel/X
rxjs 将 5 升级到 6。找不到“对象”类型的不同支持对象“”