Angular TypeScript编译中缺少in-memory-data.service.ts

Angular TypeScript编译中缺少in-memory-data.service.ts,angular,Angular,浏览Anghular tuturial,了解如何在中使用http请求 ,我说到这一点: 使用以下命令生成类src/app/in-memory-data.service.ts: ng在MemoryData中生成服务 然后我遇到了这个问题,你知道怎么解决吗 未能编译。 ./src/app/in-memory-data.service.ts 模块构建失败(来自./node_modules/@ngtools/webpack/src/index.js): 错误:/home/nart/Documents/m

浏览Anghular tuturial,了解如何在中使用http请求 ,我说到这一点:

使用以下命令生成类src/app/in-memory-data.service.ts: ng在MemoryData中生成服务

然后我遇到了这个问题,你知道怎么解决吗

未能编译。 ./src/app/in-memory-data.service.ts 模块构建失败(来自./node_modules/@ngtools/webpack/src/index.js): 错误:/home/nart/Documents/machinetransation/open translate/src/app/in-memory-data.service.ts在TypeScript编译中丢失。请通过'files'或'include'属性确保它位于您的tsconfig中。 在AngularCompilerPlugin.getCompiledFile(/home/nart/Documents/machinetransation/open translate/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:935:23) at/home/nart/Documents/machinetransation/open translate/node_modules/@ngtools/webpack/src/loader.js:42:31 在运行微任务时() 在处理和拒绝时(内部/process/task_queues.js:97:5)

这里是tsconfig.json

/*
这是一个“解决方案风格”tsconfig.json文件,编辑器和TypeScript的语言服务器使用它来改善开发体验。
它不用于执行编译。
要了解有关此文件的详细信息,请参阅:https://angular.io/config/solution-tsconfig.
*/
{
“文件”:[],
“参考资料”:[
{
“路径”:“/tsconfig.app.json”
},
{
“路径”:“/tsconfig.spec.json”
}
]

}
也面临同样的问题。最后,解决问题的方法是重新运行ng serve(更准确地说,再次单击PyCharm上的“运行”Angular CLI Server)。

您是否将服务添加到提供商

@NgModule({
  imports: [ ... ],
  declarations: [ ... ],
  providers: [
    InMemoryDataService
  ]

请在此处共享您的ts配置文件,以便我们了解添加这些文件后会发生什么情况。我假设演示应该立即运行,只需按照步骤进行。我在遵循角度教程时也面临同样的问题。这对我来说也是如此。感谢您发布答案!是的,但不知道背后的逻辑。。。