首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装npm包时/src是什么意思?

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

Stack Overflow用户
提问于 2021-10-25 01:08:36
回答 1查看 53关注 0票数 1

我试图(再次)构建一个React项目,在客户打电话给我并告诉我它已经崩溃之前,它工作得非常好。

在构建(npm run build)时,我得到的结果是:

代码语言:javascript
复制
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 repo (谷歌搜索找到的https://github.com/apollographql/graphql-tag|)的网址直接安装软件包,但结果都是一样的。

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

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

代码语言:javascript
复制
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 ]

任何有见地的人都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-25 06:17:51

在您的示例中,当与npm install一起使用时,src/ folder将触发其自己的package.json内容(as in here)的安装。

但是,如果无法访问SSH URL,则应该使用switch to HTTPS

代码语言:javascript
复制
git config --global url.https://github.com/.insteadOf git://github.com/
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69701927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档