ITPub博客

首页 > IT职业 > IT职场 > Angular CLI 升级 6.0 之后遇到的问题

Angular CLI 升级 6.0 之后遇到的问题

IT职场 作者:daqianmen 时间:2021-09-09 09:28:24 0 删除 编辑

Angular CLI 1.7.4 在使用 ng build --prod 会构建失败,而 ng build 是正常的。比较好的解决办法是使用 ng build --prod --extract-license=false 或者 ng build --prod --no-extract-license。

最近将 Angular CLI 升级到 6.X 之后,直接 ng build 会报以下错误,ng serve 也是如此。

95% emitting LicenseWebpackPlugin(node:6252) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'D:XprojectAngular-examplesangular-testnode_modules_@angular_common@6.0.2@@angularpackage.json'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at LicenseExtractor.readPackageJson (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistLicenseExtractor.js:126:23)
    at LicenseExtractor.parsePackage (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistLicenseExtractor.js:23:32)
    at ModuleProcessor.processPackage (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistModuleProcessor.js:39:46)
    at ModuleProcessor.processFile (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistModuleProcessor.js:36:21)
    at fileCallback (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistLicenseWebpackPlugin.js:101:61)
    at moduleCallback (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistLicenseWebpackPlugin.js:108:21)
    at D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistLicenseWebpackPlugin.js:120:29
    at Array.forEach ()
    at emitCallback (D:XprojectAngular-examplesangular-testnode_modules_license-webpack-plugin@1.3.1@license-webpack-plugindistLicenseWebpackPlugin.js:86:32)
    at _err0 (eval at create (D:XprojectAngular-examplesangular-testnode_modules_tapable@1.0.0@tapablelibHookCodeFactory.js:24:12), :19:1)
    at callback (D:XprojectAngular-examplesangular-testnode_modules_copy-webpack-plugin@4.5.1@copy-webpack-plugindistindex.js:77:17)
    at D:XprojectAngular-examplesangular-testnode_modules_copy-webpack-plugin@4.5.1@copy-webpack-plugindistindex.js:118:24
    at 
(node:6252) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6252) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

但是使用 ng build --prod 是正常的。同样地,使用 ng build --extract-license=false 也可以解决问题。

简单看一下,问题是由 license-webpack-plugin 插件引起的。这款插件用于输出第三方插件的许可协议。老外比较重视版权吧。但是不知道为什么总是在这个地方出问题。

感谢您的阅读,如果您对我的文章感兴趣,可以关注我的博客,我是叙帝利,下篇文章再见!

仿 Windows 照片查看器插件 https://github.com/nzbin/magnify

简化类名的轻量级 CSS 框架 https://github.com/nzbin/snack

与任意 UI 框架搭配使用的通用辅助类 https://github.com/nzbin/snack-helper

单元素纯 CSS 加载动画 https://github.com/nzbin/three-dots

原文出处

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1727/viewspace-2803375/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-07-31

  • 博文量
    108
  • 访问量
    34266