我的yarn.lock 文件中的一个依赖项存在问题。问题出在 ldapjs 上,最新版本有一个关于用户或密码中特殊字符的错误,所以我想将其冻结在最新的工作版本 1.0.2 中。
当我将代码提交到 master 分支时,构建该项目的步骤开始失败,说出标题的消息。
这是我的 dockerfile
FROM repository/node-oracle:10.15.3
LABEL maintainer="Me"
RUN yarn cache clean
# Add Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /usr/src/auth
COPY . .
RUN yarn install --frozen-lockfile --non-interactive --silent
ENV PATH /usr/src/auth/node_modules/.bin:$PATH
EXPOSE 3000
CMD ["node", "./bin/www"]
Run Code Online (Sandbox Code Playgroud)
有什么办法可以让我完成这项工作吗?
另外作为额外信息,我能够在功能分支中通过此步骤运行管道,该消息在开发和主分支中启动。
[更新]
这些是在我的yarn.lock 文件中更新和冻结的依赖项
activedirectory@^0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/activedirectory/-/activedirectory-0.7.2.tgz#19286d10c6b24a98cc906dc638256191686fa91f"
integrity sha1-GShtEMaySpjMkG3GOCVhkWhvqR8=
dependencies:
async ">= 0.1.22"
bunyan ">= 1.3.5"
**ldapjs "=1.0.2"**
underscore ">= 1.4.3"
***ldapjs@1.0.2***:
version …
Run Code Online (Sandbox Code Playgroud) continuous-integration node.js ldapjs yarnpkg yarn-lock.json
出于某种原因,该命令yarn
正在yarn.lock
使用新属性修改文件到每个依赖项:integrity
.
Git差异:
+完整性sha1-zgBCgEX7t9AxwWp7 + DV4nxU2arI =
我找不到关于它的文档,所以我的问题是 - 它是什么?
我的 asdf 有问题。\n我已经安装了最新的 Nodejs。
\nasdf install nodejs latest\n... \nasdf local nodejs latest / asdf global nodejs latest \n
Run Code Online (Sandbox Code Playgroud)\n但如果我尝试
\nyarn \xef\x80\x97 \nNo preset version installed for command yarn\nPlease install a version by running one of the following:\n\nasdf install nodejs 18.0.0\n\nor add one of the following versions in your config file at /Users/../project-name/.tool-versions\nnodejs 14.17.0\nnodejs 19.0.1\n
Run Code Online (Sandbox Code Playgroud)\n但我的项目结构中的 .tool-version 已经包含它:
\nnodejs 18.0.0\nnodejs 19.0.1\n
Run Code Online (Sandbox Code Playgroud)\n(对于我的项目,我需要nodejs >= 18)\n我正在使用苹果M1芯片。
\n"csv-file-validator": "^1.8.0"
我正在使用带有 3 个依赖项的包
famulus "2.1.2"
lodash "4.17.15"
papaparse "^5.2.0"
Run Code Online (Sandbox Code Playgroud)
我想更新/强制lodash
使用 to be的版本4.17.20
。我发现了选择性依赖解析并在我的package.json
"resolutions": {
"csv-file-validator/lodash": "^4.17.20"
}
Run Code Online (Sandbox Code Playgroud)
我删除了yarn.lock
,node_modules
文件夹并yarn install
再次运行。然而lodash版本仍然是4.17.15
csv-file-validator@^1.8.0:
version "1.8.0"
resolved "https://pkgs.dev.azure.com/RCTechnologies/EMA/_packaging/EMA/npm/registry/csv-file-validator/-/csv-file-validator-1.8.0.tgz#f8b879f533ce8c84b115d0ed2eca8e691249ec22"
integrity sha1-+Lh59TPOjISxFdDtLsqOaRJJ7CI=
dependencies:
famulus "2.1.2"
lodash "4.17.15"
papaparse "^5.2.0"
Run Code Online (Sandbox Code Playgroud)
有可能实现这一目标吗?如果是的话,我错过了什么吗?
我想验证我的项目(package.json
和yarn.lock
)中的所有依赖项是否都得到满足而无需运行yarn install
(构建整个依赖项树并发出网络请求)
起初,我非常希望这样yarn check
做。以下命令验证是否满足每个依赖项,package.json
并验证已安装的包是否与yarn.lock
文件匹配。
yarn check --integrity --verify-tree
Run Code Online (Sandbox Code Playgroud)
但是,文档说从 yarn v2 开始不推荐使用它,而yarn install --check-files
应该使用它。
但是文档--check-files
使它看起来像是做了一些完全不同的事情。
纱线安装 --check-files
验证 node_modules 中已安装的文件没有被删除。
我还可以验证运行它本质上是运行一个完整的yarn install
命令,所以它在这里没有用。
此外,删除yarn check
的拉取请求还提到了 的行为--check-files
并不完全直观。
那么在 yarn v2 及更高版本中运行此检查的支持方式是什么?有没有什么办法可以进行轻量级检查package.json
,yarn.lock
而不必像yarn install
那样通过网络构建整个依赖树?
FWIW,提出了一个类似的问题npm
,解决方案是使用该--dry-run
标志,但该标志似乎不存在于yarn
.
我使用的是yarn berry,特别是3.0.0版本,但2.4.2也有同样的问题。当我yarn install --immutable
在 CI 中运行时,出现错误:
[2021-07-27T04:51:41Z] \xe2\x9e\xa4 YN0028: \xe2\x94\x82 The lockfile would have been modified by this install, which is explicitly forbidden
。
但是,当我yarn install
在本地运行时,文件没有更改yarn.lock
。我12.22.3
在本地计算机和 CI 计算机上运行相同的节点版本。唯一的另一个区别是,在 CI 中,我在图像中运行它Alpine
,而我的本地计算机是 Mac,但我没有读到这会导致问题。
我可以做什么来进一步调试这个问题?
\n我刚刚从 GitHub 上的库中提取了一些内容,我正在使用 Windows 计算机在 VSCode 中进行编码。代码没有问题,尽管当我尝试运行 npm install 或yarn install 来获取node_modules 和yarn.lock 时,我收到一个奇怪的错误并且包不起作用。我使用 ZSH 作为 Mac 的终端。
这是错误输出:
niltonsf@Niltons-MacBook-Pro ignews.nosync % sudo yarn install
Password:
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz: incorrect data check".
info If you think this is a bug, please open a bug report with the information provided in "/Users/niltonsf/Desktop/ignews.nosync/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz: incorrect data check
error https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.2.tgz: incorrect data …
Run Code Online (Sandbox Code Playgroud) 升级到yarn 3后,当我运行时yarn install
,分辨率将从文件中删除package.json
并添加到yarn.lock
文件中。
package.json
使用yarn 3时,分辨率不应该驻留在其中吗?
我已经通读了有关 yarn 命令和 yarn.lock 的文档,我相信 yarn.lock 文件的全部意义在于使用该文件中指定的版本。
我很好奇的是:yarn.lock 中指定的版本什么时候实际使用?我在 package.jsonyarn install
和 reran 中手动更改了一个包的版本,并且更新了 yarn.lock 文件以使用新版本。我认为它会被锁定,因此在 package.json 中指定什么新版本并不重要,只要 yarn.lock 为该包指定了一个版本,它就会使用旧版本。
如果这就是 yarn.lock 应该如何工作,那么为什么不在 package.json 中指定 EXACT 版本,而不是在版本号前面使用 ~ 或 ^ 。现在我必须这样做,以便在运行时不更改 yarn.lock 文件yarn install
。
那么什么时候真正使用锁定版本/这是使用yarn.lock的正确方法吗?
是否有一个 Yarn 命令可以将node_modules 文件夹与yarn.lock 进行比较以查看是否匹配?或者,有没有办法检查自上次yarn install
运行以来是否已将新包添加到packages.json?
突然纱线不工作了。Npm 工作正常,但只能运行yarn -v,任何其他命令(例如yarn、yarn test 或yarn watch)都会显示此错误
Arguments:
/home/my.user/.nvm/versions/node/v14.15.4/bin/node /home/my.user/.nvm/versions/node/v14.15.4/bin/yarn
PATH:
/home/my.user/.nvm/versions/node/v14.15.4/bin:/home/my.user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Yarn version:
1.22.10
Node version:
14.15.4
Platform:
linux x64
Trace:
Error: EISDIR: illegal operation on a directory, read
npm manifest:
{
"name": "one",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo 'hello'"
},
"keywords": [],
"author": "",
"license": "ISC"
}
yarn manifest:
No manifest
Lockfile:
No lockfile
Run Code Online (Sandbox Code Playgroud) 在本地环境中我没有问题,但是使用此脚本在 jenkins 上运行生产环境确实可以:
yarn install --production
yarn build
Run Code Online (Sandbox Code Playgroud)
构建大约需要 5 分钟,最后,jenkins 退出并显示此控制台输出错误:
+ yarn install --production
yarn install v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > bootstrap@4.3.1" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.3.1" has unmet peer dependency "popper.js@^1.14.7".
warning " > google-maps-react@1.1.11" has incorrect peer dependency …
Run Code Online (Sandbox Code Playgroud) 我的应用程序上的yarn.lock 文件中的js-yaml 存在高严重性的git hub 安全漏洞rails
。
Remediation
Upgrade js-yaml to version 3.13.1 or later. For example:
js-yaml@^3.13.1:
version "3.13.1"
Run Code Online (Sandbox Code Playgroud)
我已经运行yarn upgrade js-yaml
它更新了我的 package.json 中的版本: "js-yaml": "^3.13.1",
然而这个问题仍然出现在github上。
我还尝试删除yarn.lock并运行yarn install
以及使用重复数据删除工具yarn-deduplicate ./yarn.lock
(该工具在其他情况下对我有用)。但是,它的古老性仍然存在。
这是 js-yaml 在我的yarn.lock 文件中的样子:
js-yaml@^3.12.0, js-yaml@^3.13.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
js-yaml@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"
integrity sha1-XJZ93YN6m/3KXy3oQlOr6KHAO4A=
dependencies:
argparse "^1.0.7"
esprima "^2.6.0"
Run Code Online (Sandbox Code Playgroud)
我想知道:
如何解决这个特定问题
保持yarn.lock 文件最新以避免安全漏洞的最佳实践是什么。看来我不是唯一一个遇到重复问题的人yarn upgrade
(例如https://github.com/yarnpkg/yarn/issues/3967),也许我可以做一些不同的事情?
yarn-lock.json ×13
yarnpkg ×10
node.js ×4
npm ×3
javascript ×2
yarnpkg-v2 ×2
apple-m1 ×1
asdf ×1
ldapjs ×1
node-modules ×1
reactjs ×1
yarn-v3 ×1
zlib ×1
zsh ×1