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

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

95% emitting LicenseWebpackPlugin(node:6252) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'D:\X\project\Angular-examples\angular-test\node_modules\_@angular_common@6.0.2@@angular\package.json'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at LicenseExtractor.readPackageJson (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\LicenseExtractor.js:126:23)
at LicenseExtractor.parsePackage (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\LicenseExtractor.js:23:32)
at ModuleProcessor.processPackage (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\ModuleProcessor.js:39:46)
at ModuleProcessor.processFile (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\ModuleProcessor.js:36:21)
at fileCallback (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\LicenseWebpackPlugin.js:101:61)
at moduleCallback (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\LicenseWebpackPlugin.js:108:21)
at D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\LicenseWebpackPlugin.js:120:29
at Array.forEach (<anonymous>)
at emitCallback (D:\X\project\Angular-examples\angular-test\node_modules\_license-webpack-plugin@1.3.1@license-webpack-plugin\dist\LicenseWebpackPlugin.js:86:32)
at _err0 (eval at create (D:\X\project\Angular-examples\angular-test\node_modules\_tapable@1.0.0@tapable\lib\HookCodeFactory.js:24:12), <anonymous>:19:1)
at callback (D:\X\project\Angular-examples\angular-test\node_modules\_copy-webpack-plugin@4.5.1@copy-webpack-plugin\dist\index.js:77:17)
at D:\X\project\Angular-examples\angular-test\node_modules\_copy-webpack-plugin@4.5.1@copy-webpack-plugin\dist\index.js:118:24
at <anonymous>
(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-licenses=false 也可以解决问题。

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

--- 2018.7.13 ---

新增解决方法:今天突然发现使用 yarn 安装依赖则没有问题。使用 npm 安装依赖之后,由于某些 angular 插件的文件夹没有 package.json(在下一层文件夹),所以 license-webpack-plugin 在抽取许可协议时会出错,但是使用 yarn 安装依赖时则不会出现这类文件夹,所以运行正常。

Angular CLI 升级 6.0 之后遇到的问题的更多相关文章

  1. Angular Cli 升级到最新版本

    1. 卸载当前版本 npm uninstall -g angular-cli 2. 清除未卸载干净的angular-cli缓存 npm cache clean -f 3. 到安装目录查看是否卸载干净 ...

  2. angular4.0 安装最新版本的nodejs、npm、@angular/cli的方法

    在使用ng项目的ui框架时,比如ng-zorro.angular Material,需要安装最新版本的@angular/cli: 配置ng-zorro框架 ng-zorro官网:https://ng. ...

  3. angular2.0入门---webStorm创建angular CLI项目

    创建项目之前需要先安装angular cli,(angular是用typescript编写的,所以先安装typescript,再安装angularjs-cli).打开命令窗口输入 npm instal ...

  4. Angular5.0之 安装指定版本Angular CLI

    我们可能会发现按照网上的方式下载安装后,使用Angular CLI生成的项目并不是我们想要的Angular的版本,因为在我们没有指定安装版本的前提下,默认会下载最新的版本安装,然而不同的Angular ...

  5. [转]【Angular4】基础(一):脚手架 Angular CLI

    本文转自:https://blog.csdn.net/u013451157/article/details/79444495 版权声明:本文为博主原创文章,未经博主允许不得转载. https://bl ...

  6. Protrator 官网和下载工具稍慢 , 但能使用. Angular CLI 内置 官方推荐 TS的 demo 不明显 , 而且依赖无法安装

    npm uninstall -g protractor  && cnpm install -g protractor && protractor --version 复 ...

  7. Angular入门到精通系列教程(6)- Angular的升级

    1. 摘要 2. https://update.angular.io/ 3. 总结 环境: Angular CLI: 11.0.6 Angular: 11.0.7 Node: 12.18.3 npm ...

  8. Angular环境准备和Angular cli

    Angular4.0来了,更小,更快,改动少 接下来为Angular4.0准备环境和学会使用Angular cli项目 1.环境准备: 1)在开始工作之前我们必须设置好开发环境 如果你的机器上还没有安 ...

  9. Visual Studio Code作为Angular开发工具常用插件安装、json-server安装与使用、angular/cli安装失败问题

    前提准备: 搭建好Angular开发环境 1 安装Visual Studio Code 教程简单,不会的去问度娘 2 安装Chrome浏览器 教程简单,不会的趣闻度娘 3 Visual Studio ...

随机推荐

  1. IIS Express 配置缓存位置

    Please refer to the three configure files to check if they contains the rule setting. "%Program ...

  2. 查看网卡及对应的IP、MAC

    #!/bin/bash# judge OS OS_release=`cat /etc/redhat-release | awk '{print $(NF-1)}'|cut -c 1`# To obta ...

  3. 【机器学习】--模型评估指标之混淆矩阵,ROC曲线和AUC面积

    一.前述 怎么样对训练出来的模型进行评估是有一定指标的,本文就相关指标做一个总结. 二.具体 1.混淆矩阵 混淆矩阵如图:  第一个参数true,false是指预测的正确性.  第二个参数true,p ...

  4. 【Netty】(4)—源码AbstractBootstrap

    源码AbstractBootstrap 一.概念 AbstractBootstrap是一个工具类,用于服务器通道的一系列配置,绑定NioEventLoopGroup线程组,指定指定NIO的模式,指定子 ...

  5. 《前端之路》之 JavaScript原型及原型链详解

    05:JS 原型链 在 JavaScript 的世界中,万物皆对象! 但是这各种各样的对象其实具体来划分的话就 2 种. 一种是 函数对象,剩下的就是 普通对象.其中 Function 和 Objec ...

  6. FileUtils【获取SD卡根目录、读写文件、移动、复制、删除文件、获取文件名、后缀名操作类】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 封装了获取SD卡根目录路径.以及对文件读写.获取文件名等相关操作. 因为需要用到android.permission.READ_EX ...

  7. 带着新人简单看看servlet到springmvc

    好久都没有写博客了,不是因为自己懒了,而是总感觉自己知道的只是太少了,每次想写博客的时候都不知道怎么下手,不过最近看到一篇博客说的是springmvc,给了我比较大的兴趣,感觉一下子对整个spring ...

  8. DotNetCore跨平台~EFCore2.0连接Mysql的烦恼-已解决

    回到目录 对于传统的nuget包,我们习惯上用官方或者大型组织的,因为它们比较考靠谱,但就在前两天.net core2.0发布后,我把efcore也升级到2.0了,mysql.EfCore也升级到支持 ...

  9. 学习ASP.NET Core Razor 编程系列十七——分组

    学习ASP.NET Core Razor 编程系列目录 学习ASP.NET Core Razor 编程系列一 学习ASP.NET Core Razor 编程系列二——添加一个实体 学习ASP.NET ...

  10. 一次快速改寫 SQL Server 高效查詢的範例

    最近線上系統突然出現匯出資料超過 10 筆時,查詢逾時的狀況,在仔細查找之後. 發現了問題原因,透過應用端與數據端兩邊同時調整,將查詢的效率提昇了約數百倍以上 首先,原本應用端的商務邏輯為每一分頁筆數 ...