Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular找不到自定义库的模块_Angular_Typescript_Server Side Rendering_Angular Universal - Fatal编程技术网

Angular找不到自定义库的模块

Angular找不到自定义库的模块,angular,typescript,server-side-rendering,angular-universal,Angular,Typescript,Server Side Rendering,Angular Universal,我在angular应用程序中实现SSR,同时尝试运行npm run build:SSR它抛出以下错误 我已经创建了自己的LIB,它是否捆绑在dist文件夹中,名称为@asfc/shared ERROR in projects/asfc-web/src/environments/environment.ts:1:39 - error TS2307: Cannot find module '@asfc/shared' or its corresponding type declarations.

我在angular应用程序中实现SSR,同时尝试运行
npm run build:SSR
它抛出以下错误

我已经创建了自己的LIB,它是否捆绑在dist文件夹中,名称为
@asfc/shared

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添加到
文件中
,但错误仍然没有消失

下面是我的,
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"
  ]
}
  "compilerOptions": {
    
    ....
    
    "paths": {
      "@asfc/shared/*": [
        "../../dist/asfc-shared/*"
      ],

    }
  },
下面是我的Dist Libs结构

dist/asfc-shared
    ├── asfc-shared.d.ts
    ├── package.json
    ├── public_api.d.ts

请提供帮助。

尝试在
tsconfig.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"
  ]
}
  "compilerOptions": {
    
    ....
    
    "paths": {
      "@asfc/shared/*": [
        "../../dist/asfc-shared/*"
      ],

    }
  },

您的配置中还排除了
dist
文件夹,但我想这与包含lib的文件夹不同。

尝试在
tsconfig.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"
  ]
}
  "compilerOptions": {
    
    ....
    
    "paths": {
      "@asfc/shared/*": [
        "../../dist/asfc-shared/*"
      ],

    }
  },
您的配置中还排除了
dist
文件夹,但我想这与包含lib的文件夹不一样