Hello, I’m trying to host on Fly for the first time. I have a basic node/Koa app and I get no errors when I build or run the script, but when I try to run flytctl launch I get the following error:
$ flyctl launch
Creating app in C:\Users\...
Scanning source code
Detected a NodeJS app
Using the following build configuration:
Builder: heroku/buildpacks:20
? App Name (leave blank to use an auto-generated name): Error Incorrect function.
There are no logs or messages and I haven’t been able to find another post regarding this issue. I get the same error on the example app or with a docker image.
server file:
import koa from 'koa'
import Router from '@koa/router'
import passport from 'koa-passport'
import session from 'koa-session'
import mongoose from 'mongoose'
import routes from './routes/authRoutes'
import './services/passport'
const app = new koa()
const router = new Router()
app.keys = [process.env['COOKIE_KEY'] as string];
mongoose.connect(process.env['MONGO_URI'] as string)
app.use(passport.initialize())
app.use(passport.session())
app.use(router.routes())
app.use(session(CONFIG, app));
routes(router)
app.use(async function handleError(ctx, next) {
try {
await next()
} catch (error) {
ctx.status = 500
ctx.body = error
}
})
const PORT = process.env['PORT'] || 5000
app.listen(PORT)
Yeah I haven’t seen that particular error either .
I don’t know the innards of the buildpacks that it is defaulting to there, so in case that is the issue, it may be worth switching to the Dockerfile approach to building an image. See if that has more luck. If you are not used to Docker (no idea) it’s simpler than it looks. You basically add a Dockerfile and .dockerignore file. And then when you run fly launch, it spots that file and takes a different approach (as the Dockerfile tells Fly how to build the image). I generally have success with that way anyway!
For a basic hello-world Node app, take a look at the files here:
You will see a bare-bones Dockerfile, .dockerignore and fly.toml already there (if you were to use the fly.toml, update the app name within it to one of your choice, naturally). Should be pretty well commented.
The original post looks like it failed when trying to generate an app name. I assume you already tried it, but did you specify an app name and it fails the same way?
I tried using Powershell instead of Git Bash for the terminal and I no longer got the error. It works on CMD as well so it seems to be an issue with Git Bash.
I’m getting the same error even when using powershell/cmd and tutorial project
PS C:\dev\my\hellonode-builtin> flyctl launch
Creating app in C:\dev\my\hellonode-builtin
Scanning source code
Detected a NodeJS app
Error name argument or flag must be specified when not running interactively
PS C:\dev\my\hellonode-builtin> flyctl version
flyctl.exe v0.0.425 windows/amd64 Commit: a1d61bdc BuildDate: 2022-10-29T21:08:47Z
PS C:\dev\my\hellonode-builtin>