AWS SAM samcli.commands.exceptions.UserException: [WinError 145] The directory is not empty

How to fix the AWS SAM error samcli.commands.exceptions.UserException: NodejsNpmBuilder:MoveDependencies – [WinError 145] The directory is not empty

samcli.commands.exceptions.UserException: NodejsNpmBuilder:MoveDependencies - [WinError 145] The directory is not empty: 'C:\\path\\to\\my\\lambda\\code\\.aws-sam\\auto-dependency-layer\\myLambdaFunction\\node_modeules\\module'

I’ve been seeing this error intermittently for some time. It comes intermittent.

Fix for [WinError 145] The directory is not empty

Just delete the .aws-sam directory whenever this error occurs or ignore it. If you run the command again it will complete successfully. I really don’t know why it’s happening or the long term fix, but it doesn’t seem to be a big deal.

If anyone else finds a resolution or has any ideas please drop them in the comments and I’ll put them into the article.

Links to other people with the same issue

Here is what google brought up for this, none of these links had fixes at the time of writing but check them yourself, maybe someone has found something out since I wrote this article.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.