You’ve heard amazing things about Cyclic. It’s so easy, fast, and simple to get your app hosted. You are ready to take the plunge.
You gather your Github and your Node.js full stack app and head over to Cyclic.sh. You sign in with Github and you are ready to hit deploy.
Yeah, go for it! We’re cheering you on. 🎉
However, depending on how your app is configured, there are a few speed bumps you might hit before your build is running smoothly. Keep reading to be prepared and get over those speedbumps for a smooth deploy!
It's generally considered best practice to used the npm module nodemon during development because it watches for file changes as you are working. However nodemon isn't needed in production.
If you are using nodemon to run your app locally, you’ll need to update the start script that tells Cyclic how to run the application before you deploy your app.
Luckily for you, Cyclic will scan your repository before the build starts and provide you with a message to this effect. Look at that! Cyclic tells you exactly what to do.
You can update your Github repo at this point and restart the build. Congratulations! Your build is complete!
Tip: As of Node 18, running with the
--watchflag gets you the same file change detection as nodemon, but without the extra dependency, e.g.
node --watch index.js
Sometimes users get caught up in the excitement of completing a build and forget to add their environment variables to Cyclic. Cyclic can see the variables you've used in your project and will give you a little push to add them the moment your build is complete.
If that message doesn't catch you, you’ll be able to see under the “Logs” tab that your application isn’t communicating with your database or any other errors that missing vars would bring, such as something being "undefined" or "not a string". Time to add those vars in the “Variables” tab.
There are already some variables in there, like your pre-populated Cyclic URL. All you have to do is add any additional variables in using the key/value pairing at the bottom.
Remember the key should match the key in your code, and if you want to copy/paste from your .env file, be sure to try out the bulk editor tab.
Once the variables are all set, check your logs again. Oh yeah, now we’re cooking with gas.
Builds using MondgoDB are very popular and run great on Cyclic, but there’s one catch… Because Cyclic is serverless, requests to MongdoDB need to be written in a certain order so they are heard correctly.
Our docs have an excellent example of how to structure your MongoClient and mongoose, if you are using it. Check it out here: https://docs.cyclic.sh/how-to/using-mongo-db
TLDR? You have to connect to MongoDB before your code starts to listen for requests, otherwise they may be missed entirely.
Once you’ve updated your MongoClient code, you should be seeing all 200s in the logs.
Speed bumps traversed! That site is live. Quick, share it with all your friends!
Are you finding other speedbumps? Let us know and we’ll do our best to help you over them.
Check out our Discord community to ask questions and share your creations: discord.cyclic.sh
Enter your email If you would like to get an email the next time we post.
We post about ~1-2x per month, and up to once a month about company news.
Fork and deploy a hello world project onto Cyclic faster than it has taken to read this page. Experience the power.Deploy on Cyclic 🚀