当包位于子文件夹内时,是否可以从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/39194648/