【发布时间】:2020-07-21 17:52:43
【问题描述】:
我在我的 Angular 应用程序中实现 SSR,而尝试运行 npm run build:ssr 它会引发以下错误。
我已经创建了自己的库,它是否捆绑在名为 @asfc/shared 的 dist 文件夹中
ERROR in projects/asfc-web/src/environments/environment.ts:1:39 - error TS2307: Cannot find module '@asfc/shared' or its corresponding type declarations.
1 import { PageNotFoundComponent } from '@asfc/shared';
~~~~~~~~~~~~~~
......
我已将 index.ts 添加到 files,但错误仍然没有消失
下面是我的tsconfig.server.json
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"removeComments": false,
"strict": false,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"experimentalDecorators": true,
"pretty": true,
"declaration": true,
"outDir": "../../dist/server",
"lib": ["es2016", "DOM"],
"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
]
},
"files": [
"server.ts",
"../../dist/asfc-shared/public_api.d.ts"
],
"angularCompilerOptions": {
"entryModule": "../../projects/asfc-web/src/app/app.server.module.ts#AppServerModule"
},
"exclude": [
"node_modules",
"dist"
]
}
下面是我的 Dist Libs 结构,
dist/asfc-shared
├── asfc-shared.d.ts
├── package.json
├── public_api.d.ts
请帮忙。
【问题讨论】:
标签: angular typescript server-side-rendering angular-universal