Error on serverless deploy: zip error: Invalid command arguments (no such option: -)
See original GitHub issueI have a serverless project, which I can deploy on one machine. When I try to deploy it on another machine, I get the following error. Both are Windows 10 .
zip error: Invalid command arguments (no such option: -)
Error ---------------------------------------------------
Error: Unexpected exit code from native zip: 16
executed command 'zip --quiet --recurse-paths ..\post-asset.zip ./'
executed in directory 'C:\Users\Administrator\Documents\ST\ST-Test-API\.webpack\post-asset'
at ChildProcess.<anonymous> (C:\Users\Administrator\Documents\ST\ST-Test-API\node_modules\bestzip\lib\bestzip.js:86:13)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
The machine that has this error can deploy OTHER serverless project without a problem. The error occurs in the webpack phase. I have not found a similar problems online.
The complete YML and output are given below:
serverless.yml
# NOTE: update this with your service name
service: test-api
# Create an optimized package for our functions
package:
individually: true
plugins:
- serverless-bundle # Package our functions with Webpack
- serverless-offline
- serverless-dotenv-plugin # Load .env as environment variables
provider:
name: aws
runtime: nodejs14.x
stage: dev
region: eu-central-1
tracing:
lambda: true
apiGateway:
request:
schemas:
post-create-model:
name: PostAddAsset
schema: ${file(schemas/post-add-asset.json)}
patch-update-model:
name: PatchAddAsset
schema: ${file(schemas/patch-update-asset.json)}
delete-model:
name: DeleteAsset
schema: ${file(schemas/delete-asset.json)}
patch-badge:
name: PatchBadge
schema: ${file(schemas/patch-badge.json)}
functions:
post-asset:
handler: post-asset.main
events:
- http:
path: asset
cors: true
method: post
integration: lambda
private: true
request:
schemas:
application/json: post-create-model
response: &response-repeat
headers:
Content-Type: "'application/json'"
template: $input.path('$')
statusCodes:
200:
pattern: "" # Default response method
template: $input.path("$.body")
409:
pattern: '.*"statusCode":409,.*' # JSON response
template: $util.parseJson($input.json('$.errorMessage')) # JSON return object
headers:
Content-Type: "'application/json'"
output
> serverless deploy --verbose
Serverless: DOTENV: Loading environment variables from .env:
Serverless: - SAMPLE_ENV_VAR
Serverless: - SLS_DEBUG
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Skipping variables resolution with old resolver (new resolver reported no more variables to resolve)
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Invoke webpack:validate
Serverless: Using configuration:
{
"packager": "npm",
"packagerOptions": {},
"webpackConfig": "node_modules\\serverless-bundle/src/webpack.config.js",
"includeModules": {
"forceExclude": [
"aws-sdk"
],
"forceInclude": null,
"packagePath": "package.json"
},
"keepOutputDirectory": false,
"concurrency": 8
}
Serverless: Removing C:\Users\Administrator\Documents\ST\ST-Test-API\.webpack
Serverless: Individually packaging with concurrency at 8 entries a time.
Serverless: Invoke webpack:compile
Serverless: Bundling with Webpack...
Serverless: Invoke webpack:package
Serverless: Fetch dependency graph from C:\Users\Administrator\Documents\ST\ST-Test-API\package.json
Serverless: No external modules needed
zip error: Invalid command arguments (no such option: -)
Error ---------------------------------------------------
Error: Unexpected exit code from native zip: 16
executed command 'zip --quiet --recurse-paths ..\post-asset.zip ./'
executed in directory 'C:\Users\Administrator\Documents\ST\ST-Test-API\.webpack\post-asset'
at ChildProcess.<anonymous> (C:\Users\Administrator\Documents\ST\ST-Test-API\node_modules\bestzip\lib\bestzip.js:86:13)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: win32
Node Version: 12.19.0
Framework Version: 2.51.0
Plugin Version: 5.4.3
SDK Version: 4.2.3
Components Version: 3.13.3
Installed version
>serverless --version
Framework Core: 2.51.0
Plugin: 5.4.3
SDK: 4.2.3
Components: 3.13.3
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
AWS NodeJS Serverless - Zip Error When Deploying Project
I've just created a boilerplate today and got the same error. I've managed to solve it specifying the serverless-webpack's version to 5.3.5.
Read more >bash zip error: Invalid command arguments (short option '\' not ...
Try: for dir in ~/Documents/CMDsh/*/ do countFolder=$((countFolder+1)) dir=${dir%*/} nameFolder=${dir##*/} zip -r -j -9 ...
Read more >Top 10 Serverless Deployment Errors (and How to Fix Them)
Invalid CloudFormation state. The error: The most common error I see our users encounter is when a deploy fails because a previous deploy...
Read more >Tutorial: Deploying a Hello World application
AWS SAM CLI error: "Security Constraints Not Satisfied" ... The prompt is informing you that the application you're about to deploy might have...
Read more >zip not supporting -S option? - Super User
output.zip . and get the error zip error: Invalid command arguments (short option 'S' not supported) . zip --version tells me
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to solve it. If you look at my .yml, you see I have serverless-bundle which has serverless-webpack as a dependency. I reverted to an older version of serverless-webpack:
npm i serverless-webpack@5.3.5
Mind you I am not the only one having problems with the newer versions of serverless-webpack! Look at https://github.com/AnomalyInnovations/serverless-bundle/issues/228
Can you test with the 5.7.0 ?