angular 使用@nguniversal/express-engine 包的 SSR 出现此错误(错误 TS6053 中的错误:未找到文件 '/project/src/server.ngtypecheck.ts'。)

angular SSR using @nguniversal/express-engine package get this error (ERROR in error TS6053: File '/project/src/server.ngtypecheck.ts' not found.)

我在 angular.When 中使用 @nguniversal/express-engine 进行服务器端呈现 我 运行 $ nmp build:ssr$ npm run dev:ssr 我收到此错误。

ERROR in error TS6053: File 'C:/dev/web/workspace/project/src/server.ngtypecheck.ts' not found.
error TS6053: File 'C:/dev/web/workspace/project/src/server.ts' not found.
error TS6053: File 'C:/dev/web/workspace/project/src/src/main.server.ngtypecheck.ts' not found.
error TS6053: File 'C:/dev/web/workspace/project/src/src/main.server.ts' not found.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.0.0 build:ssr: `ng build --prod && ng run client:server:production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@0.0.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 

有同样的问题,src/src 的 doubling-up 发生在 tsconfig.server.json。我遇到了这个错误 运行 build:ssr for Angular,这里描述的解决方案: 非常简单。我们需要编辑 src/tsconfig.server.json.

我不得不做两个改变;两者都在该解决方案中进行了描述。

导航到 src/tsconfig.server.json

  • src/main.server.ts 更改为 main.server.ts,
  • server.ts 更改为 ../server.ts

真的向其他线程提出解决方案,