【问题标题】:ng build -w # ignore non-codebase compilation errorsng build -w # 忽略非代码库编译错误
【发布时间】:2018-07-17 04:11:30
【问题描述】:

我正在使用 AngularCLI (ng) 版本 1.6.7。我正在从我无法控制的内部库中获得一些编译,例如:

https://github.com/angular/material2/issues/9816

ERROR in node_modules/@angular/material/expansion/typings/expansion-panel.d.ts(36,14): error TS2314: Generic type 'TemplatePortal<C>' requires 1 type argument(s).
node_modules/@angular/material/tabs/typings/tab-body.d.ts(62,15): error TS2314: Generic type 'TemplatePortal<C>' requires 1 type argument(s).
node_modules/@angular/material/tabs/typings/tab.d.ts(28,23): error TS2314: Generic type 'TemplatePortal<C>' requires 1 type argument(s).

由于这个编译错误,dist 目录甚至不会被写出,所以我死在水里。是否有一些标志可以与 ng build -w 一起使用,以便忽略编译错误 - 可能是我的代码库之外的编译错误?

类似:

ng build -w -i # 其中 -i 忽略错误

我试过ng build --help,我明白了:

ng build --help
ng build <options...>
  Builds your app and places it into the output path (dist/ by default).
  aliases: b
  --target (String) (Default: development) Defines the build target.
    aliases: -t <value>, -dev (--target=development), -prod (--target=production), --target <value>
  --environment (String) Defines the build environment.
    aliases: -e <value>, --environment <value>
  --output-path (Path) Path where output will be placed.
    aliases: -op <value>, --outputPath <value>
  --aot (Boolean) Build using Ahead of Time compilation.
    aliases: -aot
  --sourcemaps (Boolean) Output sourcemaps.
    aliases: -sm, --sourcemap, --sourcemaps
  --vendor-chunk (Boolean) Use a separate bundle containing only vendor libraries.
    aliases: -vc, --vendorChunk
  --common-chunk (Boolean) (Default: true) Use a separate bundle containing code used across multiple bundles.
    aliases: -cc, --commonChunk
  --base-href (String) Base url for the application being built.
    aliases: -bh <value>, --baseHref <value>
  --deploy-url (String) URL where files will be deployed.
    aliases: -d <value>, --deployUrl <value>
  --verbose (Boolean) (Default: false) Adds more details to output logging.
    aliases: -v, --verbose
  --progress (Boolean) (Default: true) Log progress to the console while building.
    aliases: -pr, --progress
  --i18n-file (String) Localization file to use for i18n.
    aliases: --i18nFile <value>
  --i18n-format (String) Format of the localization file specified with --i18n-file.
    aliases: --i18nFormat <value>
  --locale (String) Locale to use for i18n.
    aliases: --locale <value>
  --missing-translation (String) How to handle missing translations for i18n.
    aliases: --missingTranslation <value>
  --extract-css (Boolean) Extract css from global styles onto css files instead of js ones.
    aliases: -ec, --extractCss
  --watch (Boolean) (Default: false) Run build when files change.
    aliases: -w, --watch
  --output-hashing=none|all|media|bundles (String) Define the output filename cache-busting hashing mode.
    aliases: -oh <value>, --outputHashing <value>
  --poll (Number) Enable and define the file watching poll time period (milliseconds).
    aliases: -poll <value>
  --app (String) Specifies app name or index to use.
    aliases: -a <value>, -app <value>
  --delete-output-path (Boolean) (Default: true) Delete output path before build.
    aliases: -dop, --deleteOutputPath
  --preserve-symlinks (Boolean) (Default: false) Do not use the real path when resolving modules.
    aliases: --preserveSymlinks
  --extract-licenses (Boolean) (Default: true) Extract all licenses in a separate file, in the case of production builds only.
    aliases: --extractLicenses
  --show-circular-dependencies (Boolean) (Default: true) Show circular dependency warnings on builds.
    aliases: -scd, --showCircularDependencies
  --build-optimizer (Boolean) Enables @angular-devkit/build-optimizer optimizations when using `--aot`.
    aliases: --buildOptimizer
  --named-chunks (Boolean) Use file name for lazy loaded chunks.
    aliases: -nc, --namedChunks
  --subresource-integrity (Boolean) (Default: false) Enables the use of subresource integrity validation.
    aliases: -sri, --subresourceIntegrity
  --bundle-dependencies (none, all) (Default: none) Available on server platform only. Which external dependencies to bundle into the module. By default, all of node_modules will be kept as requires.
    aliases: --bundleDependencies <value>
  --service-worker (Boolean) (Default: true) Generates a service worker config for production builds, if the app has service worker enabled.
    aliases: -sw, --serviceWorker
  --skip-app-shell (Boolean) (Default: false) Flag to prevent building an app shell
    aliases: --skipAppShell
  --stats-json (Boolean) (Default: false) Generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or https://webpack.github.io/analyse.
    aliases: --statsJson

【问题讨论】:

  • 我在帮助列表中没有看到相关选项
  • 一定有办法忽略源自 node_modules 的错误?
  • 这是打字稿编译器的抱怨,Angular CLI 在后台使用它。我怀疑您是否可以“忽略”错误,但您必须查看 tsc 选项,而不是 ng build 选项才能找到类似的内容。尝试查找错误的来源可能更容易。 @angular/material 是有信誉的包,我想可以通过调整一些版本号来修复。

标签: webpack angular-cli webpack-dev-server webpack-2 angular5


【解决方案1】:

您应该安装正确版本的@angular/cdk@5.1.1。

看到这个link

【讨论】:

  • 是的,我认为@angular/cdk 应该与@angular/cli 的版本相同
  • 不,不幸的是,这可能不是我正在寻找的答案。我希望有一个可以构建应用程序的标志,即使它们无法编译,尽管该标志可能不存在。这取决于编译错误,有些错误不能忽略,例如错误的 import 语句。
猜你喜欢
  • 2011-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-07
  • 2018-06-21
  • 1970-01-01
  • 2017-11-04
  • 2018-03-17
相关资源
最近更新 更多