1

在客户打电话告诉我它已经崩溃之前,我尝试(再次)构建一个运行良好的 React 项目。

在构建(npm run build)时,我得到了这个:

Creating an optimized production build...
Failed to compile.

./src/utils/graphql.js
Cannot find module: 'graphql-tag/src'. Make sure this package is installed.

You can install this package by running: npm install graphql-tag/src.

然而,当我运行给定的命令时,npm install graphql-tag/src它只是保持超时,试图通过 ssh 进入似乎是 github 存储库的内容。我只是不明白为什么它会尝试使用 SSH,因为我知道当我查看 packages.json 文件时,我只能找到这个特定包的 github 存储库的 http URL。

我尝试以经典方式安装该软件包,该软件包npm install graphql-tag运行良好,但是当我重新启动构建时,我遇到了同样的失败。

我什至尝试使用其 github 存储库的 URL 直接安装该软件包(https://github.com/apollographql/graphql-tag | 通过谷歌搜索找到),但它最终以相同的方式结束。

我还尝试删除文件夹 node_modules 并重新安装所有npm i.

最后,这是我在npm install graphql-tag/src查看日志文件时使用建议的命令时得到的结果cat /home/plagiat/.npm/_logs/2021-10-25T00_40_42_148Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'graphql-tag/src' ]
2 info using npm@6.14.11
3 info using node@v12.21.0
4 verbose npm-session a25edec68e8c749c
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly pacote Retrying git command: ls-remote -h -t git://github.com/graphql-tag/src.git attempt # 2
8 silly pacote Retrying git command: ls-remote -h -t git://github.com/graphql-tag/src.git attempt # 3
9 silly pacote Retrying git command: ls-remote -h -t ssh://git@github.com/graphql-tag/src.git attempt # 2
10 silly pacote Retrying git command: ls-remote -h -t ssh://git@github.com/graphql-tag/src.git attempt # 3
11 silly fetchPackageMetaData error for github:graphql-tag/src Error while executing:
11 silly fetchPackageMetaData /usr/bin/git ls-remote -h -t ssh://git@github.com/graphql-tag/src.git
11 silly fetchPackageMetaData
11 silly fetchPackageMetaData ssh: connect to host github.com port 22: Connection timed out
11 silly fetchPackageMetaData fatal: Could not read from remote repository.
11 silly fetchPackageMetaData
11 silly fetchPackageMetaData Please make sure you have the correct access rights
11 silly fetchPackageMetaData and the repository exists.
11 silly fetchPackageMetaData
11 silly fetchPackageMetaData exited with error code: 128
12 timing stage:rollbackFailedOptional Completed in 0ms
13 timing stage:runTopLevelLifecycles Completed in 53964ms
14 verbose stack Error: exited with error code: 128
14 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/pacote/lib/util/finished.js:12:19)
14 verbose stack     at ChildProcess.emit (events.js:314:20)
14 verbose stack     at maybeClose (internal/child_process.js:1022:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
15 verbose cwd /home/plagiat/AntiPlagiat/client
16 verbose Linux 5.4.0-73-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "graphql-tag/src"
18 verbose node v12.21.0
19 verbose npm  v6.14.11
20 error Error while executing:
20 error /usr/bin/git ls-remote -h -t ssh://git@github.com/graphql-tag/src.git
20 error
20 error ssh: connect to host github.com port 22: Connection timed out
20 error fatal: Could not read from remote repository.
20 error
20 error Please make sure you have the correct access rights
20 error and the repository exists.
20 error
20 error exited with error code: 128
21 verbose exit [ 1, true ]

任何见解将不胜感激。

4

1 回答 1

0

在您的情况下,src/ 文件夹将在与 一起使用时npm install触发安装其自己的package.json内容(如此处)(如果存在)。

但是,如果无法访问 SSH URL,则应切换到 HTTPS

git config --global url.https://github.com/.insteadOf git://github.com/
于 2021-10-25T06:17:50.513 回答