安装 npm 包时 /src 是什么意思?

What the /src means when installing npm package?

我尝试(再次)构建一个运行良好的 React 项目,然后客户打电话给我并告诉我它崩溃了。

构建时 (npm 运行 构建) 我刚得到这个:

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 文件时我只能找到一个 http URL 到这个特定包的 github 仓库。

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

我什至尝试直接使用其 github 存储库的 URL 安装软件包(https://github.com/apollographql/graphql-tag | 通过 google 搜索找到)但它只是结束了同理

我也试过删除文件夹 node_modules 并重新安装所有 npm i

最后,当我使用 cat /home/plagiat/.npm/_logs/2021-10-25T00_40_42_148Z-debug.log

查看日志文件时,使用建议的命令 npm install graphql-tag/src 得到的结果
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 ]

如有任何见解,我们将不胜感激。

在您的情况下, would, when used with npm install, trigger the installation of its own package.json content (as in here),如果存在。

但是,如果无法访问 SSH URL,您应该 。

git config --global url.https://github.com/.insteadOf git://github.com/