Bower 无法安装 Faker@3.1.0

Bower unable to install Faker@3.1.0

我们有一个旧的 ember 应用有 bower.json 配置如下:

{
  "name": "my-app",
  "dependencies": {
    "Faker": "~3.1.0"
  }
}

它已经工作了多年,最近我们在构建时发现以下错误

bower install
bower Faker#~3.1.0          not-cached https://github.com/Marak/Faker.js.git#~3.1.0
bower Faker#~3.1.0             resolve https://github.com/Marak/Faker.js.git#~3.1.0
bower Faker#~3.1.0        ENORESTARGET No tag found that was able to satisfy ~3.1.0

Additional error details:
No versions found in https://github.com/Marak/Faker.js.git

我查了https://github.com/Marak/Faker.js,错误是对的。没有3.1.0了,当前版本是6.6.6。但是 git 提交历史找不到 3.1.0 版本了。

有没有办法让我从某个地方找回 3.1.0?看来作者清除了旧版本?

如 GitHub 存储库中的 What happened with faker.js, the library's original maintainer erased the whole history of the repository. Older versions of Faker are still available via npm install; resolving them from the NPM registry is stable, as they prevent popular packages being unpublished since the left-pad debacle. However the tags no longer exist 中所述,因此 Bower 无法找到包。

有个community-maintained fork of faker.js that you could switch to, even though new Bower packages cannot be created. Per the Bower documentation:

As Bower is deprecated, registering new Bower packages is not supported anymore. Neverthless you can install any GitHub repository as Bower package by putting full name in bower.json:

{
  "dependencies": {
    "angular-cli": "angular/angular-cli#^9.1.3"
  }
}

You can install any dependency from github with CLI as well:

bower install angular/angular-cli --save

因此,对于您的情况,您应该能够按如下方式解决问题:

{
  "name": "my-app",
  "dependencies": {
    "Faker": "faker-js/faker#~3.1.0"
  }
}