Python & Elm in the same project: npm not available?

Hello!

I try to setup a glitch with Python/Flask for the back end and Elm for the front end.

I’ve put a glitch.json containing the following:

{
  "install": "pip3 install --user -r requirements.txt && npm install -g elm",
  "start": "npm run 'elm make src/Main.elm --output public/elm.js' && PYTHONUNBUFFERED=true python3 server.py",
  "watch": {
    "ignore": [
      "\\.pyc$"
    ],
    "install": {
      "include": [
        "^requirements\\.txt$"
      ]
    },
    "restart": {
      "include": [
        "\\.py$",
        "^start\\.sh"
      ]
    },
    "throttle": 1000
  }
}

I have following error in the logs:
/opt/watcher/app-types/custom/install.sh: line 9: npm: command not found

How can I use npm in a Python project?

Hi @sebsheep, when it comes to Python you don’t need to use npm to run your scripts. The contents of the start and install scripts are just bash commands, so whatever you would typically use at a Linux command prompt should work fine by itself. I think you can probably just get rid of the npm run on this command and it should run, or at least return a more helpful error message, although i haven’t tried that with this specific command.

Hope that helps!

Thank you for the answer. The thing is that I thought I was NEEDED npm (since Elm is a npm package). But there is also a “npm-free” binary available :smiley: which solves my issue.

Oh, I see my confusion; sorry about that!

If you wanted to use Node / NPM on the “front end” and Python on the backend you could do that - it would just be a little convoluted because you’d have to have install and start scripts in your package.json file that took care of the pip install and starting up the backend as well as managing the frontend packages using Glitch’s built-in tools. But if you’re happy with what you’ve got then that’s awesome!