node.jsnpmamazon-elastic-beanstalkcodeship

Deploy issues with deploying to elastic beanstalk "Refusing to delete"


Hi I've stumbled upon this error while trying to deploy my new code to our test environment but all of sudden it crashes.

Works just fine on my machine but suddenly on AWS it crashes on deploys.

eb-activity.log

  npm ERR! path /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp
  npm ERR! code EEXIST
  npm ERR! Refusing to delete /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp: is outside /tmp/deployment/application/node_modules/hummus/node_modules/node-pre-gyp and not a link
  npm ERR! File exists: /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp

Looking deeper into the logs it says

/tmp/.npm/_logs/2019-01-21T12_50_51_067Z-debug.log

624 verbose unbuild rmStuff node-pre-gyp@0.10.3 from /tmp/deployment/application/node_modules
625 verbose unbuild rmStuff in /tmp/deployment/application/node_modules/hummus/node_modules
626 silly isEverInside /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp is not inside /tmp/deployment/application/node_modules/hummus/node_modules/node-pre-gyp
627 silly gentlyRm parent.path = /tmp/deployment/application/node_modules/hummus/node_modules/node-pre-gyp
628 silly gentlyRm parent.managed = /tmp/deployment/application/node_modules/hummus/node_modules/node-pre-gyp is in /tmp/deployment/application
629 silly gentlyRm target.path =  /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp
630 silly gentlyRm target.symlink = null
631 silly gentlyRm target.managed = /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp is in /tmp/deployment/application
632 silly gentlyRm target.inParent =  false
633 verbose unlock done using /tmp/.npm/_locks/staging-6d252812679aa9c6.lock for /tmp/deployment/application/node_modules/.staging
634 verbose stack Error: Refusing to delete /tmp/deployment/application/node_modules/hummus/node_modules/.bin/node-pre-gyp: is outside /tmp/deployment/application/node_modules/hummus/node_modules/node-pre-gyp and not a link

I'm letting CodeShip deploy all the code, which packages the node_modules and uploads it to AWS.

But now when I'm trying to do a $ eb deploy DEV-APP --profile dev it works just fine.

  > hummus@1.0.95 install /tmp/deployment/application/node_modules/hummus
  > node-pre-gyp install --fallback-to-build $EXTRA_NODE_PRE_GYP_FLAGS

  node-pre-gyp WARN Using request for node-pre-gyp https download
  [hummus] Success: "/tmp/deployment/application/node_modules/hummus/binding/hummus.node" already installed
  Pass --update-binary to reinstall or --build-from-source to recompile

Only when I let CodeShip do my deploys, it does not work at all.


Solution

  • Ok so I did conclude that my own deploy didn't add node_modules to the S3 bucket, which CodeShip added.

    Therefore I just added a deploy script to remove node_modules before deploying to elastic beanstalk.