在NODE docker镜像上安装zip后,仍然出现zip: command not found的问题

65次阅读
没有评论

问题描述

在使用Azure的kudu zipdeploy端点时,尝试对dist文件夹进行压缩并上传,但无论他自己安装了哪个压缩包,都会出现这个错误。
用户使用的docker镜像是weltn24/up-docker-node-chrome-headless,标签为chrome-66_node-10.0_yarn-1.6.0。
在用户的yml文件中,以下部分失败了:

build:
  stage: build
  script:
    - apt-get install p7zip p7zip-full
    - yarn install
    - ./node_modules/@angular/cli/bin/ng build --prod
    - cd dist/AngularTemplate; zip -r ../dist.zip *; cd ..; cd..
artifacts:
  paths:
    - dist.zip

在第4行的命令zip -r ../dist.zip *失败,提示zip: command not found。

解决方案

请注意以下操作注意版本差异及修改前做好备份。

解决方案1

根据最佳回答,你需要安装正确的zip软件包,并将归档文件放在正确的文件夹中。
以下是修正后的脚本:

build:
  stage: build
  script:
    - apt-get install zip unzip
    - yarn install
    - ./node_modules/@angular/cli/bin/ng build --prod
    - cd dist/AngularTemplate; zip -r ../../dist.zip *; cd ..; cd..
artifacts:
  paths:
    - dist.zip

在上面的修正后的脚本中,我们使用apt-get install zip unzip命令安装了正确的zip软件包。然后,我们将归档文件放在了正确的文件夹中,即../../dist.zip
请注意,根据用户的描述,他之前安装的是错误的zip软件包,并将归档文件放在了错误的文件夹中。

解决方案2

如果解决方案1仍然无法解决问题,你可以尝试使用其他的压缩工具来替代zip命令。
例如,你可以尝试使用tar命令来创建tar归档文件:

build:
  stage: build
  script:
    - apt-get install tar
    - yarn install
    - ./node_modules/@angular/cli/bin/ng build --prod
    - cd dist/AngularTemplate; tar -czvf ../../dist.tar.gz *; cd ..; cd..
artifacts:
  paths:
    - dist.tar.gz

在上面的示例中,我们使用apt-get install tar命令安装了tar工具。然后,我们使用tar -czvf ../../dist.tar.gz *命令创建了一个tar归档文件。
请注意,使用tar命令创建的归档文件需要使用相应的工具进行解压缩。

解决方案3

如果以上解决方案仍然无法解决问题,你可以尝试使用其他的docker镜像,或者检查docker镜像中是否已正确安装zip软件包。
你可以查看docker镜像的Dockerfile或者相关文档,确认zip软件包是否已正确安装。
如果docker镜像中没有预装zip软件包,你可以尝试在构建镜像时添加相应的安装命令。
请注意,根据用户的描述,他使用的docker镜像是weltn24/up-docker-node-chrome-headless,你可以查看该镜像的相关文档或者联系镜像的维护者,获取更多关于zip软件包的信息。
以上是几种可能的解决方案,希望能帮助你解决问题。如果问题仍然存在,请提供更多详细信息,以便我们能够更好地帮助你解决问题。

正文完