【问题标题】:Webpack failure during JHipster Prod PackageJHipster Prod Package 期间的 Webpack 失败
【发布时间】:2018-08-14 09:53:43
【问题描述】:

我生成了一个普通的 JHipster 微服务网关。随着 JHipster 注册表的运行,我可以使用 ./mvnw 启动它并且它可以工作。我可以使用./mvnw -Pdev package 打包它,并且可以。但是,如果我尝试使用 ./mvnw -Pprod package 打包它,它显然会在 webpack 构建产品步骤中失败。

  • JHipster 版本 4.14.0
  • 纱线版本​​ 1.3.2
  • 节点版本 v6.11.5

yo-rc.json

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "org.jhipster.blog",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.14.0",
    "baseName": "blog",
    "packageName": "org.jhipster.blog",
    "packageFolder": "org/jhipster/blog",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "0b9d434149a3efef6af7362acaf33585d5eaa492",
    "clientFramework": "angularX",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "gateway",
    "testFrameworks": [
      "gatling",
      "protractor"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "es"
    ]
  }
}

Maven 输出

[INFO] --- frontend-maven-plugin:1.6:yarn (webpack build prod) @ blog ---
[INFO] yarn not inheriting proxy config from Maven
[INFO] Running 'yarn run webpack:prod' in /Users/mschreiber/temp/microservice-demo/blog
[INFO] yarn run v1.3.2
[INFO] $ yarn run cleanup && yarn run webpack:prod:main && yarn run clean-www
[INFO] $ rimraf target/{aot,www}
[INFO] $ yarn run webpack -- --config webpack/webpack.prod.js --profile
[ERROR] warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.
[INFO] $ node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config webpack/webpack.prod.js --profile
[INFO] MergetJsonsWebpackPlugin compilation started...
[INFO] MergetJsonsWebpackPlugin compilation completed...
[ERROR] buffer.js:202
[ERROR]   throw new TypeError(kFromErrorMsg);
[ERROR]   ^
[ERROR] 
[ERROR] TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
[ERROR]     at Function.Buffer.from (buffer.js:202:9)
[ERROR]     at new Buffer (buffer.js:158:17)
[ERROR]     at writeOut (/Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/lib/Compiler.js:334:17)
[ERROR]     at require.forEach (/Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/lib/Compiler.js:345:12)
[ERROR]     at /Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/node_modules/async/dist/async.js:3096:16
[ERROR]     at eachOfArrayLike (/Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/node_modules/async/dist/async.js:1055:9)
[ERROR]     at eachOf (/Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/node_modules/async/dist/async.js:1103:5)
[ERROR]     at Object.eachLimit (/Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/node_modules/async/dist/async.js:3158:5)
[ERROR]     at emitFiles (/Users/mschreiber/temp/microservice-demo/blog/node_modules/webpack/lib/Compiler.js:315:21)
[ERROR]     at /Users/mschreiber/temp/microservice-demo/blog/node_modules/mkdirp/index.js:30:20
[ERROR]     at FSReqWrap.oncomplete (fs.js:135:15)
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[ERROR] error Command failed with exit code 1.
[INFO] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:05 min
[INFO] Finished at: 2018-03-06T08:32:03-05:00
[INFO] Final Memory: 44M/372M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn (webpack build prod) on project blog: Failed to run task: 'yarn run webpack:prod' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

【问题讨论】:

  • 耶!终于有人遇到和我一样的问题了。我确认

标签: jhipster


【解决方案1】:

此问题与 JHipster 的 workbox-webpack-plugin 依赖关系有关,已在 v4.14.1 release (related commit) 中修复。要在生成的项目中修复它,请进行以下更改:

package.json:

-    "workbox-webpack-plugin": "3.0.0-alpha.3",
+    "workbox-webpack-plugin": "3.0.0-beta.1",

webpack/webpack.prod.js

-        new WorkboxPlugin({
+        new WorkboxPlugin.GenerateSW({

您还可以使用yarn global upgrade generator-jhipster 升级到最新的generator-jhipster 版本,然后使用jhipster upgrade 升级您的项目。有关升级命令的更多信息,请参阅relevant documentation

【讨论】:

  • 谢谢!我没有更改代码,而是按照发布页面上的说明将 JHipster 的版本升级到 4.14.1 (yarn global upgrade generator-jhipster),然后在项目目录中运行 jhipster upgrade。它做了你上面提到的改变(可能还有其他改变)。
猜你喜欢
  • 2019-01-10
  • 1970-01-01
  • 2019-03-12
  • 2019-01-12
  • 1970-01-01
  • 2020-01-30
  • 2019-03-13
  • 2020-09-09
  • 1970-01-01
相关资源
最近更新 更多