当运行 ng serve 我的代码编译失败并给出这个错误:
ERROR in node_modules/@angular/compiler-cli/src/transformers/program.d.ts(9,23): error TS2307: Cannot find module 'path'.
我认为这与我的本地 Angular 版本比我的全局版本旧版本有关,所以我尝试了 this solution
但这并没有帮助。现在要编译我的代码,我必须删除一个“;”在我的项目中随机的某个地方,保存项目,添加分号并保存项目。使用这种方法,我的代码可以编译并且我的应用程序可以运行,但错误仍然存在。
最佳答案
读完这个 ( https://github.com/angular/angular-cli/issues/9151 ) 我意识到我的 .ts 文件中某处有一个错误的导入语句:
import {Definition} from "@angular/compiler-cli";
但它应该是:
import {Definition} from "path/in/my/src/folder";
我建议在工作空间中搜索:“@angular/compiler-cli”并检查它在这个地方是否正确。
关于angular - 在 program.d.ts 中找不到模块 'path',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50565354/