gpt4 book ai didi

git - npm 从裸 git 文件 repo 安装

转载 作者:太空狗 更新时间:2023-10-29 13:26:33 28 4
gpt4 key购买 nike

如何从裸 git repo 文件夹安装 npm 模块?

所以我有一个包含 git 存储库的文件夹。它是用 git init --bare 创建的。现在我想让 npm 获取最新版本的 master 分支,那里有一个可用的 package.json 文件。

正确的做法是什么?

我试过类似的东西:

npm install git+file:///W:/my/git/repo/ -g
npm install git+file:///W:/my/git/repo/#master -g
npm install file:///W:/my/git/repo/ -g --from-git

有可能吗?

npm 日志:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'file:///W:/my/git/repo/',
1 verbose cli '-g',
1 verbose cli '--from-git' ]
2 info using npm@1.4.14
3 info using node@v0.10.29
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose cache add [ 'file:///W:/my/git/repo/', null ]
6 verbose cache add name=undefined spec="file:///W:/my/git/repo/" args=["file:///W:/my/git/repo/",null]
7 verbose parsed url { protocol: 'file:',
7 verbose parsed url slashes: true,
7 verbose parsed url auth: null,
7 verbose parsed url host: '',
7 verbose parsed url port: null,
7 verbose parsed url hostname: '',
7 verbose parsed url hash: null,
7 verbose parsed url search: null,
7 verbose parsed url query: null,
7 verbose parsed url pathname: '/W:/my/git/repo/',
7 verbose parsed url path: '/W:/my/git/repo/',
7 verbose parsed url href: 'file:///W:/my/git/repo/' }
8 silly lockFile cc42952a--W-my-git-repo file:///W:/my/git/repo/
9 verbose lock file:///W:/my/git/repo/ C:\Users\myusername\AppData\Roaming\npm-cache\cc42952a--W-my-git-repo.lock
10 silly lockFile cc42952a--W-my-git-repo file:///W:/my/git/repo/
11 silly lockFile cc42952a--W-my-git-repo file:///W:/my/git/repo/
12 error addLocal Could not install file:///W:/my/git/repo/
13 error Error: ENOENT, stat 'C:\test\file:\W:\my\git\repo'
14 error If you need help, you may report this *entire* log,
14 error including the npm and node versions, at:
14 error <http://github.com/npm/npm/issues>
15 error System Windows_NT 6.2.9200
16 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "file:///W:/my/git/repo/" "-g" "--from-git"
17 error cwd C:\test
18 error node -v v0.10.29
19 error npm -v 1.4.14
20 error path C:\test\file:\W:\my\git\repo
21 error code ENOENT
22 error errno 34
23 verbose exit [ 34, true ]

最佳答案

我有一个老掉牙的答案,这可能比根本没有答案要好。使用 Git 的 URL 重写功能:

git config --global url.file://.insteadOf git+file://
npm install git+file:///c:\dev\code\mymod

它会生成有关无法获取 Remote 等的警告,但它会安装模块,并且 npm 会以成功代码退出。

这是有效的,因为 git+ 前缀使 NPM 将整个路径传递给 Git,然后 URL 重写规则变成 git+file://(一个无效的 Git 协议(protocol)string) 到 file://(一个有效的 Git 协议(protocol)字符串)。

关于git - npm 从裸 git 文件 repo 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24910573/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com