使用@nguniversal/express-engine 包的 angular SSR 收到此错误(错误 TS6053 中的错误:找不到文件“/project/src/server.ngtypecheck.ts”。)

mf3*_*340 3 node.js npm server-side-rendering angular

我正在使用@nguniversal/express-engine 在 angular 中进行服务器端渲染。当我运行$ 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. 
Run Code Online (Sandbox Code Playgroud)

小智 5

有同样的问题,src/src从 tsconfig.server.json 发生加倍。我在运行 build:ssr for Angular 时遇到了这个错误,这里描述的解决方案:npm run build:ssr 在 angular 8 中不起作用非常简单。我们需要编辑 src/tsconfig.server.json。

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

导航 src/tsconfig.server.json

  • 更改src/main.server.tsmain.server.ts
  • 更改server.ts../server.ts

真正为另一个线程提供解决方案的道具,