当包位于子文件夹中时,是否可以从github安装npm包?
例如,我们有Microsoft BotBuilder存储库:
https://github.com/Microsoft/BotBuilder
但是我需要在子文件夹“Node/core/”内安装软件包:
https://github.com/Microsoft/BotBuilder/tree/master/Node/core/
那么,如何使用npm安装它呢?
最佳答案
添加到package.json
中:
...
"scripts": {
"postinstall": "mkdir BotBuilder; cd BotBuilder; git init; git remote add -f origin https://github.com/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
脚本正在运行。并逐步:
mkdir BotBuilder
cd BotBuilder
git init
git remote add -f origin https://github.com/Microsoft/BotBuilder.git
git config core.sparseCheckout true
Node/core
添加到结帐列表:echo "Node/core" >> .git/info/sparse-checkout
git pull --depth=1 origin master
cd ..
npm i ./BotBuilder/Node/core/
关于git - 来自github repo子文件夹的npm install软件包,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47536022/