Angular CLI 升级 6.0 之后遇到的问题
2018-05-19 11:31
337 查看
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 安装依赖时则不会出现这类文件夹,所以运行正常。
相关文章推荐
- iOS升级至iOS10之后遇到的问题(一)
- 升级Xcode8之后 XMPP 遇到重定义的问题 Redefinition of module 'dnssd'
- 关于升级14.1.0 build-7370693之后遇到的问题
- 关于升级14.1.0 build-7370693之后遇到的问题
- 升级到AndroidStudio3.0之后项目打包遇到的问题及解决方案
- Tomcat升级到6.0遇到的双引号改单引号问题
- xcode8升级之后项目遇到了问题
- MacBook Pro 升级 Mac OS X Lion 10.7.3 之后遇到的WiFi共享问题
- Tomcat升级到6.0遇到的双引号改单引号问题
- Xcode8升级之后遇到的问题
- lucene版本升级到4.6.0以上之后使用mmseg4j分词器遇到的问题
- xcode8.0升级之后公司项目遇到的问题
- 升级到AndroidStudio3.0 之后的遇到问题的处理(新建、方法数限制等)
- 32位升级到64位之后迁移oracle db遇到的问题
- cmake升级之后遇到的cmake问题的解决方案
- 将ubuntu14.04 从mysql从5.5删除之后安装5.7遇到的一些问题(本篇不讨论热升级)
- 升级到appcompat v7 21.0.2之后遇到的问题解决方法
- Android升级到2.3之后遇到的问题
- AndroidStudio低版本(1.5)升级到高版本(2.1)之后你可能会遇到的其中一个项目构建问题
- Oracle技术之32位升级到64位之后迁移oracle db遇到的问题