从 Vaadin 13 迁移到 Vaadin 14 时如何修复 "Could not locate bower" 错误

How to fix "Could not locate bower" error while migrating from Vaadin 13 to Vaadin 14

我正在尝试将我的 Vaadin 应用程序从第 13 版迁移到第 14 版。我正在按照迁移指南进行操作:https://vaadin.com/docs/v14/flow/v14-migration/v14-migration-guide.html 一步一步。

一切顺利,直到我必须按照本指南将 Polymer2 升级到 Polymer3https://vaadin.com/docs/v14/flow/v14-migration/migration-tool.html

执行以下命令 mvn vaadin:migrate-to-p3 returns com.vaadin.flow.migration.MigrationToolsException: Could not locate bower. Install it manually on your system and re-run migration goal. 但是我在全局和本地都安装了凉亭。

bower -v returns 1.8.8

这是我的 package.json 的样子:

{
  "name": "no-name",
  "license": "UNLICENSED",
  "dependencies": {
    "@polymer/polymer": "3.2.0",
    "@webcomponents/webcomponentsjs": "^2.2.10",
    "polymer-modulizer": "^0.4.3"
  },
  "devDependencies": {
    "bower": "^1.8.8",
    "copy-webpack-plugin": "5.0.3",
    "raw-loader": "3.0.0",
    "webpack": "4.30.0",
    "webpack-babel-multi-target-plugin": "2.1.0",
    "webpack-cli": "3.3.0",
    "webpack-dev-server": "3.3.0",
    "webpack-merge": "4.2.1"
  },
  "description": "This project can be used as a starting point to create your own Vaadin Flow application with Spring Boot.\r It contains all the necessary configuration and some placeholder files to get you started.",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "http://git.ws.com.pl:3000/ck/vaadin-mi.git"
  },
  "author": ""
}

有人知道怎么解决吗?

我遇到了同样的问题 运行在 Windows 10 上使用迁移工具。

作为解决方法,我使用 Docker 到 运行 :

  • 安装Docker
  • 运行 a Maven image,我使用 Maven 3 和 openjdk 11(挂载您的 Maven 存储库以防止重新下载所有依赖项):

    docker run -it --rm -v c:/[path to your maven repo]:/root/.m2/repository -v c:/[path to your maven project]:/usr/src/myproject -w /usr/src/myproject --entrypoint "/bin/sh" maven:3-jdk-11

  • 然后在容器中安装node和npm :

    curl -sL https://deb.nodesource.com/setup_12.x | bash -

    apt-get install -y nodejs

  • 安装凉亭:

    npm install -g bower

  • 允许 运行使用 root 访问 bower

    echo '{ "allow_root": true }' > /root/.bowerrc

  • 运行迁移工具

    mvn vaadin:migrate-to-p3