serverless-webpack icon indicating copy to clipboard operation
serverless-webpack copied to clipboard

ENOTEMPTY error during serverless package

Open dls314 opened this issue 7 years ago • 9 comments

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:<path>.webpack<path>'

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):

  • https://github.com/johnagan/clean-webpack-plugin/issues/59

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

dls314 avatar Oct 18 '18 22:10 dls314

Same issue here

kvr2277 avatar Jun 02 '19 21:06 kvr2277

@kvr2277 Are you also using Windows?

hassankhan avatar Jun 02 '19 23:06 hassankhan

hi any update on this issue?

Nilesh-TDSystems avatar Jul 09 '19 08:07 Nilesh-TDSystems

@hassankhan I am seeing this on Windows

mwoodsmall avatar Aug 13 '19 15:08 mwoodsmall

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

mwoodsmall avatar Aug 14 '19 11:08 mwoodsmall

~/.../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)

jasonrberk avatar Apr 09 '20 21:04 jasonrberk

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

MarkovCredit avatar Aug 06 '20 18:08 MarkovCredit

I'm getting this without serverless webpack...

ariel-frischer avatar Mar 04 '21 06:03 ariel-frischer

Me too when running from an external drive.

ZeldOcarina avatar May 15 '23 10:05 ZeldOcarina