本文介绍了来自 github repo 子文件夹的 npm 安装包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
制作用于克隆 repo 的文件夹:mkdir BotBuilder 进入文件夹:cd BotBuilder init git repo: git init 将 git origin 设置为 Microsoft/BotBuilder 存储库:git remote add -f origin github/Microsoft/BotBuilder.git 启用稀疏结帐:git config core.sparseCheckout true 将 Node/core 添加到结帐列表:echo "Node/core" >>.git/info/sparse-checkout pull 部分仓库:git pull --depth=1 origin master 进入你的应用文件夹:cd .. 安装 BotBuilder:npm i ./BotBuilder/Node/core/
Make folder to clone repo: mkdir BotBuilder
enter to the folder: cd BotBuilder
init git repo: git init
set git origin to Microsoft/BotBuilder repo: git remote add -f origin github/Microsoft/BotBuilder.git
enable sparse checkout: git config core.sparseCheckout true
add Node/core to checkout list: echo "Node/core" >> .git/info/sparse-checkout
pull part of repo: git pull --depth=1 origin master
enter to Your app folder: cd ..
install BotBuilder: npm i ./BotBuilder/Node/core/
当包位于子文件夹中时,是否可以从 github 安装 npm 包?
Is it possible to install npm package from github when the package located inside subfolder?
例如,我们有 Microsoft BotBuilder 存储库:github/Microsoft/BotBuilder
For example, we have Microsoft BotBuilder repository: github/Microsoft/BotBuilder
但我需要在子文件夹Node/core/"中安装包:github/Microsoft/BotBuilder/tree/master/Node/核心/
But I need to install package inside subfolder "Node/core/": github/Microsoft/BotBuilder/tree/master/Node/core/
那么我如何使用 npm 安装它?
So how can I install it with npm?
推荐答案添加到 package.json:
... "scripts": { "postinstall": "mkdir BotBuilder; cd BotBuilder; git init; git remote add -f origin github/Microsoft/BotBuilder.git; git config core.sparseCheckout true; echo "Node/core" >> .git/info/sparse-checkout; git pull --depth=1 origin master; cd ..; npm i ./BotBuilder/Node/core/" ... }, ...postinstall 脚本在安装包后运行.
postinstall script is running after the package is installed.
一步一步:
更多推荐
来自 github repo 子文件夹的 npm 安装包
发布评论