Failed during stage 'preparing site for deployment': exit status 1

I very suddenly had deploys start failing. The first error wasn’t with a code change— it was uploading an image through Netlify CMS. Everything has failed after that.

I get this error:

failed during stage 'preparing site for deployment': exit status 1

I’ve reverted to the last successfully building commit and tried clearing the cache and doing a new deploy, but that made no difference.

Here’s a couple of build logs, including the first to fail:

The site is using Eleventy, for what it’s worth. Please let me know what else I can provide that would be useful.

Thanks!

Thanks, Bret, I really appreciate the quick help! Adding encoding did the trick.

My deploy-succeeded.js is based very closely on Max Böck’s, and I think many other people have done the same, since he wrote a great article about it. I notice he also doesn’t have the module, so I think there’s a good chance this issue may pop up for others.

Thanks again!

3 Likes

FYI this issue is being tracked publicly here on GitHub and has some more information about the “why”: encoding not found when requiring node-fetch · Issue #30 · netlify/zip-it-and-ship-it · GitHub . It’ll also help you to know when you can remove that extra dependency since we’ll update it as we work :slight_smile:

2 Likes

Hello, I’ve added encoding but it didn’t work. It seems to look for './dist/react-hot-loader.production.min.js' from '/opt/build/repo/dist/lambda' I’ve never had this problem before and I didn’t touch functions. Thoughts?

12:42:06 PM: Build script success
12:42:06 PM: Starting to prepare functions from 'dist'
12:42:06 PM: Zipping functions from /opt/build/repo/dist/lambda to /tmp/zisi-087720367
12:42:07 PM: Error: Cannot find module './dist/react-hot-loader.production.min.js' from '/opt/build/repo/dist/lambda'
12:42:07 PM: Failing build: Failed to prepare functions for deployment
12:42:07 PM: failed during stage 'preparing functions for deployment': exit status 1
12:42:08 PM: Finished processing build request in 1m47.046320424s
12:42:08 PM: Shutting down logging, 0 messages pending

Edit: I’ve updated netlify-lambda to "^1.4.5" and produced a different error which seems like a separate (babel?) issue:

2:55:12 PM: Module build failed (from ../node_modules/babel-loader/lib/index.js):
2:55:12 PM: Error: Plugin/Preset files are not allowed to export objects, only functions. In /opt/build/repo/node_modules/react-static/babel-preset.js
2:55:12 PM:     at createDescriptor (/opt/build/repo/node_modules/@babel/core/lib/config/config-descriptors.js:178:11)
...
2:55:12 PM:     at Object.loader (/opt/build/repo/node_modules/babel-loader/lib/index.js:56:18)
2:55:13 PM: Done in 53.07s.

Update: I figured it out. To anyone out there using react-static (older versions ~before v6.x.x) with netlify-lambda (v0.4.0), I needed to upgrade both my versions of react-static(now v7.x.x) and netlify lambda(now v1.4.5).

hey @cliffasaurus! Good job on figuring out your issue. Would you mind pulling out your question and starting a separate thread so the next person who has the same issue can find it more easily?? thanks!

I’ll second that…

Although I would also be interested if anyone has modified Max’s function to work with Jekyll. IIRC, his previous site was built using that before he moved to Eleventy.

Following allowing with @bridgestew’s post on the subject (who, like Max, used Eleventy), there are some things left unexplained related to Jekyll’s templates, how to test locally, and get syndication working when you deploy.

Is the use of Lambda functions tied to CI on the Netlify side of things? E.g, can I generate the function and the site before running netlify-cli manually instead of having deploys happen automatically?

Hi @chrisfinazzo, can you provide more details on what you’re trying to accomplish?

Netlify functions can be triggered using URL’s, they aren’t specifically tied in to our CI notification system. You can create functions and use it for lots of things. There’s more info on Netlify functions in our docs.

I want to syndicate a JSON Feed of my site’s posts to Twitter.

My concerns re CI v building the site and function “offline” comes from the fact that the version of Jekyll I’m using - and its underlying Ruby version - is newer than what you might get using Netlify’s GitHub integration.

The same thinking applies to my pre-deployment scripts, which I run during the build process.

Ideally, my process would look something like the following using a modfied version of deploy-succeeded.js as a Lambda function to kick off the syndication:

bundle exec jekyll build & netlify-lambda build functions & git push origin master & netlify deploy --prod -d _site

Hi @chrisfinazzo, if you are concerned about ruby versions, you can set the version used in our buildbots by setting a .ruby-version as described in our build settings doc. You Jekyll version is dictated by what you have in your Gemfile.lock file.

I’m still not quite clear what your question is, though. Is the event-triggered function not triggering when trying that process you mentioned? What exact issue are you running into? Just want to get a better understanding. Thanks.