无法运行任何纱线/纱线升级/纱线添加而没有错误

Posted

技术标签:

【中文标题】无法运行任何纱线/纱线升级/纱线添加而没有错误【英文标题】:Can't run any yarn/yarn uprade/yarn add without error 【发布时间】:2021-11-09 15:35:31 【问题描述】:

这是我第二次遇到这个问题,但这次找不到有效的解决方案。

问题:yarn/yarn install/yarn add 无法正常工作,尽管在运行 yarn 并创建我的 node_modules 之后,我可以键入 yarn start 并且我的项目可以运行,我也可以运行 yarn add examplePackage 和它已成功添加到 node_modules 中。

    [4/4] Rebuilding all packages...
[-/6] ⢀ waiting...
[2/6] ⢀ grpc
[3/6] ⢀ node-sass
[-/6] ⢀ waiting...
error /home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build --library=static_library
Arguments: 
Directory: /home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.13.0
node-pre-gyp info using node@14.17.5 | linux | x64
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp info check checked for "/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node" (not found)
node-pre-gyp http GET https://node-precompiled-binaries.grpc.io/grpc/v1.20.3/node-v83-linux-x64-glibc.tar.gz
node-pre-gyp http 404 https://node-precompiled-binaries.grpc.io/grpc/v1.20.3/node-v83-linux-x64-glibc.tar.gz
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.20.3/node-v83-linux-x64-glibc.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for grpc@1.20.3 and node@14.17.5 (node-v83 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp http 404 status code downloading tarball https://node-precompiled-binaries.grpc.io/grpc/v1.20.3/node-v83-linux-x64-glibc.tar.gz 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@14.17.5 | linux | x64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@14.17.5 | linux | x64
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /usr/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                       ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:390:12)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
gyp ERR! System Linux 5.13.13-1-MANJARO
gyp ERR! command "/usr/local/lib/nodejs/node-v14.17.5-linux-x64/bin/node" "/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc
gyp ERR! node -v v14.17.5
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/lib/nodejs/node-v14.17.5-linux-x64/bin/node /home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Linux 5.13.13-1-MANJARO
node-pre-gyp ERR! command "/usr/local/lib/nodejs/node-v14.17.5-linux-x64/bin/node" "/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc
node-pre-gyp ERR! node -v v14.17.5
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/lib/nodejs/node-v14.17.5-linux-x64/bin/node /home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/node/extension_binary/node-v83-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/lessnet/Dokumenty/Programowanie/Inne/crwn-clth/node_modules/grpc/src/n

我目前正在使用当前 Node LTS 运行 Manjaro Pahvo。

我试过了:

rm -rf node_modules yarn clean cache 重新安装整个 repo 重新安装纱线 将 python2 安装为 node-gyp 或 node-pre-gyp 需要它

【问题讨论】:

你能试试运行yarn install --force,它相当于npm rebuild吗?也许您可以共享您的 package.json 依赖项。所以人们可以尝试一下。 【参考方案1】:

grpc 包似乎有问题。看看 Github 中为 grpc 提出的这个问题:

https://github.com/grpc/grpc-node/issues/1181

问题建议使用@grpc/grpc-js 而不是grpc,因为grpc 已被弃用。

【讨论】:

以上是关于无法运行任何纱线/纱线升级/纱线添加而没有错误的主要内容,如果未能解决你的问题,请参考以下文章

纱线安装命令时出现 ESOCKETTIMEDOUT 错误

在 github 上的 Dependabot 警报后升级特定包纱线锁

纱线无法添加包(工作区内外)

无法在纱线工作区 monorepo 中添加包

Rails 6 无法导入纱线依赖项:未捕获错误:模块解析失败:意外字符“#”(1:0)

带有 --dev 标志的纱线错误“没有这样的选项”