Make my project run a command if it needs to start

so I have a project (Glitch :・゚✧) and I want it to run npm start/node index.js when it starts after stopping

i have to manually do npm start if I want it to run and it works, but it won’t work if I stop it and need glitch to start it when I visit the website

I even put in a glitch.json thingy but it doesn’t do anything

when I stop npm start I see
failed to start application on rich-level-ketch.glitch.me

This is most likely because your project has a code error.
Check your project logs, fix the error and try again.

when glitch tries to start it after inactivity it is stuck on “starting…”

so how do I fix it

1 Like

what does the glitch.json do? I think you only need the package.json file

my json file is just

{
    "start": "npm start"
}
package.json
{
  "name": "nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/node": "^18.0.6",
    "body-parser": "^1.20.2",
    "cookie-parser": "^1.4.6",
    "crypto-js": "^4.2.0",
    "express": "^4.18.2",
    "node-fetch": "^3.2.6"
  }
}

can you send the docs for glitch.json?

docs? I was scrolling through some forum posts on here and someone posted that for a python glitch.json thing. I just changed the start command to npm.

idk where the documentation is

what did the post say?

this was the post

I think you misread that? it says to put that in package.json, not glitch.json

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.