Unable to deploy NodeJS/TypeScript to Fly.io

Hey,

I’ve got an issue deploying a nodejs app with typescript, everything I run flyctl deploy it shows me the following:

[Installing yarn]
[INFO] Installing yarn@1.22.17
[INFO] No file to start server
[INFO] either use ‘docker run’ to start container or add index.js or server.js
/cnb/buildpacks/heroku_nodejs-yarn/0.1.8/lib/build.sh: line 26: error: command not found
ERROR: failed to build: exit status 127
Error executing lifecycle: failed with status code: 51

Does anybody have any advice? That would be super appreciated

Hi @Johnny_Liaw

Looks like the build pack is unable to find a file.
Are you able to post your fly.toml and package.json files?

Is this related?

@charsleysa sure will do

fly.toml below

# fly.toml file generated for morning-firefly-8723 on 2022-01-30T17:22:54+11:00

app = "morning-firefly-8723"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  builder = "heroku/buildpacks:20"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"


package.json below

{
  "name": "expense-dashboard-server",
  "version": "1.0.0",
  "description": "",
  "main": "server.ts",
  "scripts": {
    "start": "node server.ts",
    "start dev": "nodemon server.ts",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@prisma/client": "^3.8.1",
    "express": "^4.17.2"
  },
  "devDependencies": {
    "@types/express": "^4.17.13",
    "@types/node": "^17.0.13",
    "nodemon": "^2.0.15",
    "prettier": "2.5.1",
    "prisma": "^3.8.1",
    "ts-node": "^10.4.0",
    "typescript": "^4.5.5"
  }
}

Appreciate any help that I could get with this :pray:

Ah interesting. Potentially? I do have a yarn.lock in my project, would the potential solution be trying to delete your yarn.lock? @FrequentFlyer

If you have a yarn.lock file then the buildpack will use yarn.

If you want to use npm then check out these docs:
Heroku Node.js Support | Heroku Dev Center

1 Like

Like @charsleysa’s link says, if yarn.lock is present, yarn will be used; else npm.

Sorry, I’m not from the front-end world, so I’m only trying my best to be useful :slight_smile:
When looking up this error message, I did find that for some project, using Node 17 borked the dependencies.
Is it an option to try with Node 16 (the active LTS release)?
Or heroku_nodejs-yarn/ 0.1.6 or 0.1.7 or something.

Also, seeing that the fly.toml was auto-generated, did you start with a Dockerfile?
If so, can you paste that as well please.

Hi @Johnny_Liaw ,

Can you try adding cmd = "yarn start" to the [experimental] section of fly.toml, and re-deploy to see how it goes.

Since it’ll then find the yarn.lock, the above will just be like giving yarn a kick.
Rather than removing yarn.lock, which will make it use npm for the build, etc.

Cross-referencing issues: https://community.fly.io/t/deploy-error-with-flyctl-actions-failed-to-launch-determine-start-command-failed-due-to-unhealthy-allocations/

https://fly.io/docs/reference/configuration/#the-experimental-section

1 Like