gpt4 book ai didi

javascript - 如何让 yarn 不对许可证字段发出警告?

转载 作者:IT老高 更新时间:2023-10-28 23:00:47 26 4
gpt4 key购买 nike

在运行 yarn install 时,即使我已经定义了许可证,但每次都没有提交许可证时,我都会看到一条警告:

$ jq . package.json 
{
"name": "license-example",
"version": "1.0.0",
"main": "index.js",
"license": "UNLICENSED",
"dependencies": {
"lodash": "^4.17.4",
"moment": "^2.18.1"
}
}

根据npm defintion应该是有效的:

Finally, if you do not wish to grant others the right to use a private or unpublished package under any terms:

{ "license": "UNLICENSED" }

这是输出:

yarn install
yarn install v0.27.5
warning ../package.json: No license field
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.09s.

我的主要目标是让该警告消失,但我也不想提供无效的开源许可证来使警告消失,即使它是一个永远不会在外部看到的内部项目.

如何在不出现警告的情况下将 yarn 项目标记为专有?

最佳答案

对于 yarnnpm,默认行为是它们查找父目录。

我的主文件夹中有一个过时且被遗忘的 package.json 没有许可证字段:

~/package.json

在我的项目中运行 yarn install 时:

~/my-project/package.json

yarn 然后也在我的主目录中找到了那个并报告了那个错误。我把它误认为是我项目的 package.json

警告通过在路径前面加上父文件夹的 .. 来明确这一点。

warning ../package.json: No license field

删除过时的 package.json 后,我得到了预期的输出:

yarn install v0.27.5
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.88s.

关于javascript - 如何让 yarn 不对许可证字段发出警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45690202/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com