Jhipster 应用程序:使用 Maven 打包时 Bower 出现问题

Jhipster application : issue with bower when packaging with maven

我正在开发 Jhipster 应用程序 (v3.0.0)。 我知道这是一个旧版本,但也许有人遇到过这个问题。
我已经尝试使用
安装凉亭 - 纱线
- npm(使用 sudo 否则我无法安装它,我遇到了 EACCESS 问题)

当我打包我的 webapp 时,我收到了这个错误:

[INFO] --------------------------------------
[INFO]          BOWER INSTALL --NO-COLOR
[INFO] --------------------------------------
bower ESUDO         Cannot be run with sudo

Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814

You can however run a command with sudo using --allow-root option
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.224 s
[INFO] Finished at: 2018-02-07T09:07:37+01:00
[INFO] Final Memory: 49M/517M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.trecloux:yeoman-maven-plugin:0.5:build (run-frontend-build) on project rh-app: Error during : bower install --no-color: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.trecloux:yeoman-maven-plugin:0.5:build (run-frontend-build) on project rh-app: Error during : bower install --no-color
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error during : bower install --no-color
    at com.github.trecloux.yeoman.YeomanMojo.executeCommand(YeomanMojo.java:129)
    at com.github.trecloux.yeoman.YeomanMojo.logAndExecuteCommand(YeomanMojo.java:110)
    at com.github.trecloux.yeoman.YeomanMojo.bowerInstall(YeomanMojo.java:91)
    at com.github.trecloux.yeoman.YeomanMojo.execute(YeomanMojo.java:69)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 26 more
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
    at com.github.trecloux.yeoman.YeomanMojo.executeCommand(YeomanMojo.java:127)
    ... 31 more

我不知道怎么解决。
如果有人有想法...

谢谢

要运行 bower 作为root 用户,您需要在.bowerrc 中添加allow_root 键(位于项目的根目录)

{
    "directory": "src/main/webapp/bower_components",
    "allow_root": true
}

附带说明一下,在使用 NPM 安装软件包时不应使用 sudo。请参阅 "How to Prevent Permissions Errors"

上的 NPM 文档