我在一个Angular5项目中有一个导入语句:
import {plugins, SCECodeGenType} from 'sce-plugins/code-generation';这将解决我的文件系统上的这个路径:
/Users/.../suman-chrome-extension/node_modules/sce-plugins/code-generation/index.d.ts在使用ng build -w构建应用程序时,我会得到以下错误:
ERROR in ../sce-plugins/code-generation/index.ts Module build failed: Error: /Users/alexamil/WebstormProjects/oresoftware/sumanjs/sce-plugins/code-generation/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:662:23)
at plugin.done.then (/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/node_modules/@ngtools/webpack/src/loader.js:467:39)
at <anonymous> @ ./src/app/shared/services/lang.service.ts 14:24-62 @ ./src/app/app.module.ts @ ./src/main.ts @ multi ./src/main.ts我相信这是因为我正在使用npm link链接'sce-plugins'项目以进行本地开发。
我在这里看到了将npm link与Angular5项目结合使用的一些问题:
https://github.com/angular/angular-cli/issues/3875
https://github.com/angular/angular-cli/issues/8677
https://github.com/angular/angular-cli/issues/9376
有人知道怎么修吗?
更新:
它似乎不适用于npm link perse或符号链接。如果我简单地将本地目录复制到node_modules/sce-plugins,就会得到同样的错误。然而,如果我npm install sce插件到node_modules,那么我就不会得到错误。很奇怪,好像是角质层,而不是NPM。
发布于 2018-02-15 00:24:44
因此,在再次阅读了这个Github问题之后:https://github.com/angular/angular-cli/issues/8284
我在.angular-cli.json中做了这个改变
"defaults": {
"build": {
"preserveSymlinks": true // <<<< add this
},
"styleExt": "scss",
"component": {
}
}现在,考虑到preserveSymlinks标志和我的tsconfig.app.json文件中的include字段:
"include":[
"./**/*.ts",
"../node_modules/sce-plugins/**/*.ts"
],我现在可以将'sce-plugins'符号链接到我的主项目中,而不是手动复制文件。您可能根本不需要"include"字段,尽管我发现如果删除"include"字段,它将无法工作。
发布于 2018-09-07 14:24:34
在角6 "angular.json“文件中,需要将"preserveSymlinks”放在“选项”下面:
"defaults": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"preserveSymlinks": true,
"outputPath": "dist/ConsoleClient",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/web.config"
],发布于 2020-01-27 17:10:25
在将我的应用程序从角5迁移到6时,我遇到了同样的问题,修复了我已经应用的程序:
includes array 在 of tsconfig.app.json中添加了缺失文件的条目(注意:文件名不是tsconfig.json)
另外,请确保您所提到的丢失文件的路径相对于tsconfig.app.json。
https://stackoverflow.com/questions/48797135
复制相似问题