Serverless-webpack: ENOTEMPTY error during serverless package

Created on 19 Oct 2018  路  8Comments  路  Source: serverless-heaven/serverless-webpack

This is a (Bug Report / Feature Proposal)

Bug Report

Description

While running serverless package, sometimes I see an error ENOTEMPTY: directory not empty, rmdir 'c:\.webpack\'

For bug reports:

  • What went wrong?
  • What did you expect should have happened?
  • What was the config you used?
  • What stacktrace or error message from your provider did you see?
Serverless: Packaging service...

  Error --------------------------------------------------

  ENOTEMPTY: directory not empty, rmdir 'c:\...\.webpack\...'

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: ENOTEMPTY: directory not empty, rmdir '...\.webpack\...'
    at Object.fs.rmdirSync (fs.js:846:18)
    at rmkidsSync (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:304:27)
    at rmdirSync (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:281:7)
    at rimrafSync (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:252:7)
    at options.readdirSync.forEach.f (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:291:39)
    at Array.forEach (<anonymous>)
    at rmkidsSync (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:291:26)
    at rmdirSync (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:281:7)
    at Object.rimrafSync (c:\...\node_modules\serverless-webpack\node_modules\fs-extra\lib\remove\rimraf.js:252:7)
    at ServerlessWebpack.cleanup (c:\...\node_modules\serverless-webpack\lib\cleanup.js:13:11)
From previous event:
    at PluginManager.invoke (C:\Users\...\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:390:22)
    at PluginManager.run (C:\Users\...\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:421:17)
    at variables.populateService.then.then (C:\Users\...\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:157:33)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at Serverless.run (C:\Users\...\AppData\Roaming\npm\node_modules\serverless\lib\Serverless.js:144:8)
    at serverless.init.then (C:\Users\...\AppData\Roaming\npm\node_modules\serverless\bin\serverless:43:50)
    at <anonymous>

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           8.12.0
     Serverless Version:     1.32.0

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.
  • If there is additional config how would it look

Similar or dependent issue(s):

Additional Data

  • Serverless-Webpack Version you're using: 5.2.0
  • Webpack version you're using: 4.20.2
  • Serverless Framework Version you're using: 1.32.0
  • Operating System: Windows
  • Stack Trace (if available): Above
bug

All 8 comments

Same issue here

@kvr2277 Are you also using Windows?

hi any update on this issue?

@hassankhan I am seeing this on Windows

It is happening when trying to cleanup the output directory, so a workaround is to set this in your serverless.yml file:

custom:
  webpack:
    keepOutputDirectory: true

With that set it won't attempt to cleanup the .webpack directory

~/.../integrations-aws-jobs-nicb/packages/processing [use-sls-for-build !?]> npm run package

[email protected] fu /Users/me/repos/ghe/integrations-aws-jobs-nicb/packages/processing
sls package

Assertion Error ----------------------------------------

AssertionError [ERR_ASSERTION]: rimraf: missing path
at Object.rimrafSync (/Users/jason.berk/repos/ghe/integrations-aws-jobs-nicb/packages/processing/node_modules/serverless-webpack/node_modules/fs-extra/lib/remove/rimraf.js:231:3)
at processConfig (/Users/jason.berk/repos/ghe/integrations-aws-jobs-nicb/packages/processing/node_modules/serverless-webpack/lib/validate.js:161:13)
at ServerlessWebpack.validate (/Users/jason.berk/repos/ghe/integrations-aws-jobs-nicb/packages/processing/node_modules/serverless-webpack/lib/validate.js:229:14)

I am running into the same problem where my .serverless directory is effectively locked with an empty requirements directory within it. The ENOTEMPTY error doesn't happen after every deployment but when it does, the only solution is to reboot or sign out.

Has anyone found a fix?

I have added the following to my serverless.yml file but the issue persists:
webpack:
keepOutputDirectory: true

I'm getting this without serverless webpack...

Was this page helpful?
0 / 5 - 0 ratings