Amplify-cli: ✖ Zipping artifacts failed.

Created on 11 Jun 2020  Â·  16Comments  Â·  Source: aws-amplify/amplify-cli

Describe the bug
amplify publish builds correctly but fails on zip artifacts.

Amplify CLI Version
4.21.3

To Reproduce
$ amplify publish

Expected behavior
amplify should be enable to zip and perform publish.
the message should be accurate on how and where it failed.

Desktop (please complete the following information):

  • OS: Mac 10.13.6
  • Node Version: v13.2.0

Additional context
Please ask.

enhancement hosting

Most helpful comment

check that it is building in the directory you expect if angular 5+ i believe it should not be just dist but dist/whatever your angular project name is

{
    "projectName": "growroom",
    "version": "3.0",
    "frontend": "javascript",
    "javascript": {
        "framework": "angular",
        "config": {
            "SourceDir": "src",
            **"DistributionDir": "dist/angular-app",**
            "BuildCommand": "npm run-script build",
            "StartCommand": "ng serve"
        }
    },
    "providers": [
        "awscloudformation"
    ]
}

All 16 comments

Hello @mluis
What kind of error message is shown?
To better reproduce this are you able to share your project to [email protected]?

The only message shown was "Zipping artifacts failed." and the app quit. Perhaps I should had written a better issue title.

I had to setup everything again. On my end the project is now running although I couldn't understand what was wrong before.

check that it is building in the directory you expect if angular 5+ i believe it should not be just dist but dist/whatever your angular project name is

{
    "projectName": "growroom",
    "version": "3.0",
    "frontend": "javascript",
    "javascript": {
        "framework": "angular",
        "config": {
            "SourceDir": "src",
            **"DistributionDir": "dist/angular-app",**
            "BuildCommand": "npm run-script build",
            "StartCommand": "ng serve"
        }
    },
    "providers": [
        "awscloudformation"
    ]
}

@jonnyparko I think the cli should state exactly what's the problem.

@mluis Ah gotcha I see that now. My bad!

In case of React app, your_app/amplify/.config/project-config.json should be something like this:

{
    "projectName": "blah",
    "version": "3.0",
    "frontend": "javascript",
    "javascript": {
        "framework": "react",
        "config": {
            "SourceDir": "src",
            "DistributionDir": "dist",
            "BuildCommand": "npm run-script build",
            "StartCommand": "npm run-script start"
        }
    },
    "providers": [
        "awscloudformation"
    ]
}

Any update on this one? there is not even an error on the console, what is _Zipping artifacts failed_ supposed to mean?

If you are using gatsby, you need to make sure that "DistributionDir": "public", that's how I solved it

I'm getting ZIPPING ARTIFACTS FAILED when i tried amplify publish from amplify CLI. The problem is no error is written. I didn't do any fancy thing. This is my first time and i simply followed tutorial steps in amplify. Code build part is successful. After that immediately getting ZIPPING ARTIFACTS FAILED with no trace of error or message. A zipped file of Zero KB size is getting created in root folder though

@Freakrishnal if you can show your __app/amplify/.config/project-config.json_ file, or even your project, that could help

@Rolando-Barbella this is my project-config.json. You can find code here https://github.com/Freakrishnal/FirstAmplify.git

{
"projectName": "TestAmplify1",
"version": "3.0",
"frontend": "javascript",
"javascript": {
"framework": "angular",
"config": {
"SourceDir": "src",
"DistributionDir": "dist/TestAmplify1",
"BuildCommand": "npm.cmd run-script build",
"StartCommand": "ng serve"
}
},
"providers": [
"awscloudformation"
]
}

@Freakrishnal I can't see anything wrong, to be honest, you can always delete the _amplify_ folder and do the whole thing again, sorry if I can't offer you a better solution

https://docs.amplify.aws/start/getting-started/setup/q/integration/angular

check if the directory that the app will be served from exists. For me, I was using Next and React and Amplify console was looking for directory named "out", but the build command in my package.json was not correct. I changed the package.json's build command and the "out" directory was created and Amplify was able to zip it without any issues/

I also had the not so helpful "Zipping artifacts failed." message after pulling down a project on a new development environment.

As mentioned above, setting the javascript.config.DistributionDir to the correct build directory resolved the issue for me.
The file to look at is amplify/.config/project-config.json

It looks like the generic error is thrown here https://github.com/aws-amplify/amplify-cli/blob/2c84b71687a0ebcdeb92ebe462c8cf4eab8c9e3c/packages/amplify-console-hosting/hosting/manual/publish.js#L31-L34

https://github.com/aws-amplify/amplify-cli/blob/2c84b71687a0ebcdeb92ebe462c8cf4eab8c9e3c/packages/amplify-console-hosting/hosting/manual/publish.js#L52-L60

Without knowing more about the codebase - Possibly moving the configuration out of this scope and checking the directory exists before triggering the zip is the solution?

  • Get config
  • Check path exists or throw error "Build Path doesn't exist error"
  • Pass buildPath and projectPath to zipArtifacts - the generic response is applicable for other failures

My Problem was I put "DistributionDir": "build" instead of "DistributionDir": "dist" and it works

I also had the not so helpful "Zipping artifacts failed." message after pulling down a project on a new development environment.

As mentioned above, setting the javascript.config.DistributionDir to the correct build directory resolved the issue for me.
The file to look at is amplify/.config/project-config.json

It looks like the generic error is thrown here

https://github.com/aws-amplify/amplify-cli/blob/2c84b71687a0ebcdeb92ebe462c8cf4eab8c9e3c/packages/amplify-console-hosting/hosting/manual/publish.js#L31-L34

https://github.com/aws-amplify/amplify-cli/blob/2c84b71687a0ebcdeb92ebe462c8cf4eab8c9e3c/packages/amplify-console-hosting/hosting/manual/publish.js#L52-L60

Without knowing more about the codebase - Possibly moving the configuration out of this scope and checking the directory exists before triggering the zip is the solution?

  • Get config
  • Check path exists or throw error "Build Path doesn't exist error"
  • Pass buildPath and projectPath to zipArtifacts - the generic response is applicable for other failures

Woww...This really helped. My issue is fixed. project path is coming wrong in my case.

Was this page helpful?
0 / 5 - 0 ratings