npm 依赖上传Nexus教程

1.准备好依赖,要求是tgz

image

image

 

2.在traversePublishScript.sh脚本当前目录执行脚本

脚本中的ip、端口、仓库名、账号、密码要改成真实的

image

 

traversePublishScript.sh

#!/bin/bash
#第三步创建的tgz文件路径
targetDir=D:/MyData/应用部署配置/前端部署/test 
publishRestful=http://10.10.1.56:8081/service/rest/v1/components?repository=npm-hosted
echo ">>> 文件所在目录:$targetDir <<<"

function traverse() {
    for file in "$1"/*
    do
        if [ -d "$file" ] ; then
            traverse "$file"
        else
            # 在这里执行您想要对每个文件执行的操作
            echo ">>> $targetDir/$file 上传开始 \n"
            ret=`curl -u admin:It091872@ -X POST "$publishRestful" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -F "npm.asset=@$file;type=application/x-compressed"`
            echo $ret
            echo ">>> $targetDir/$file 上传完成 \n"
            echo "$file"
        fi
    done
}

traverse $targetDir

 

posted @ 2025-08-12 09:51  咔咔皮卡丘  阅读(96)  评论(0)    收藏  举报