javascript 如何在 Bower 中设置软件包最新版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18815655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 13:19:15  来源:igfitidea点击:

How to set package latest version in Bower?

javascriptbower

提问by Vitalii Korsakov

I was watching this nice videoabout requirejs, backbone and bower and something does not work for me. How can I set latest version of package in bower.jsonfile? In video Jeff says that nullshould be used to define latest version like this

我正在观看有关 requirejs、backbone 和 bower 的精彩视频,但有些东西对我不起作用。如何在bower.json文件中设置最新版本的包?在视频中,Jeff 说应该使用null来定义这样的最新版本

{
    "name": "project name",
    "version": "1.0.0",
    "dependencies": {
        "backbone-amd": null,
        "underscore-amd": null,
        "requirejs": null
    }
}

But I have an exception in console that I can't use nullvalue as version number. I couldn't find any info at bower wiki. Does anybody know how to solve this?

但是我在控制台中有一个例外,我不能使用值作为版本号。我在 bower wiki 上找不到任何信息。有谁知道如何解决这个问题?

采纳答案by Dan G.

That should work.

那应该有效。

Make sure you are running the latest version of Bower. I am currently running v1.2.6 and null works to fetch the latest dependency.

确保您运行的是最新版本的 Bower。我目前正在运行 v1.2.6 并且 null 可以获取最新的依赖项。

$ bower -v

If you have installed bower globally via npm, then you can update it this way:

如果你已经通过 npm 全局安装了 bower,那么你可以这样更新它:

$ npm update bower -g

Note: you may need to run that as sudo depending on your file permissions.

注意:根据您的文件权限,您可能需要将其作为 sudo 运行。

Hope this helps.

希望这可以帮助。

回答by Ian Lim

If you are using bower version 1.2.x, this should work:

如果您使用的是 bower version 1.2.x,这应该可以工作:

{
    "name": "project name",
    "version": "1.0.0",
    "dependencies": {
        "backbone-amd": "latest",
        "underscore-amd": "latest",
        "requirejs": "latest"
    }
}

回答by édouard Lopez

You can use the latestkeyword when installing a package. Be aware that you can get some dependencies issues :

您可以latest在安装软件包时使用关键字。请注意,您可能会遇到一些依赖性问题:

bower install --save font-awesome#latest
bower font-awesome#4.1.0    not-cached git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower font-awesome#4.1.0       resolve git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower font-awesome#4.1.0      download https://github.com/FortAwesome/Font-Awesome/archive/v4.1.0.tar.gz
bower font-awesome#4.1.0       extract archive.tar.gz
bower font-awesome#4.1.0      resolved git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower font-awesome#4.1.0    not-cached git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower font-awesome#4.1.0       resolve git://github.com/FortAwesome/Font-Awesome.git#4.1.0
bower font-awesome#4.1.0      download https://github.com/FortAwesome/Font-Awesome/archive/v4.1.0.tar.gz
bower font-awesome#4.1.0       extract archive.tar.gz
bower font-awesome#4.1.0      resolved git://github.com/FortAwesome/Font-Awesome.git#4.1.0

There is a -Fflagthat can go even further:

有一个-F标志可以走得更远:

-F, --force-latest      Force latest version on conflict
-F, --force-latest      Force latest version on conflict

回答by Lucas Serafim

I have found an easy alternative, instead of updating manually, you could use one command:

我找到了一个简单的替代方法,您可以使用一个命令,而不是手动更新:

First install this:

首先安装这个:

npm install -g bower-check-updates

Then run the bcuto check for the updates

然后运行bcu以检查更新

bcu

bcu

After check, bcu -uto upgrade your bower.json and its done!

检查后,bcu -u升级您的 bower.json 并完成!

More details and source:

更多细节和来源:

bower-check-updates - is totally clone of npm-check-updates, but it updates bower.json dependencies (bower-check-updates updates bower.json).

bower-check-updates - 完全是 npm-check-updates 的克隆,但它更新 bower.json 依赖项(bower-check-updates 更新 bower.json)。

Source: https://www.npmjs.com/package/bower-check-updates

来源:https: //www.npmjs.com/package/bower-check-updates

回答by Harry

npm install -g npm-check-updates
npm-check-updates --packageManager bower 

source: https://www.npmjs.com/package/bower-check-updates

来源:https: //www.npmjs.com/package/bower-check-updates