{"id":15059577,"url":"https://github.com/davidcavazos/elm-in-node-example","last_synced_at":"2026-01-02T06:03:03.443Z","repository":{"id":148553051,"uuid":"271629768","full_name":"davidcavazos/elm-in-node-example","owner":"davidcavazos","description":"Example to show how to run Elm code in a Node application","archived":false,"fork":false,"pushed_at":"2020-06-11T19:50:11.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T19:48:32.151Z","etag":null,"topics":["command-line","elm","elm-demos","elm-lang","elm-language","example","node","node-js","nodejs","nodejs-server","server","serverless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidcavazos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T19:23:35.000Z","updated_at":"2020-06-11T19:50:13.000Z","dependencies_parsed_at":"2023-05-20T12:00:18.891Z","dependency_job_id":null,"html_url":"https://github.com/davidcavazos/elm-in-node-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcavazos%2Felm-in-node-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcavazos%2Felm-in-node-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcavazos%2Felm-in-node-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidcavazos%2Felm-in-node-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidcavazos","download_url":"https://codeload.github.com/davidcavazos/elm-in-node-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243681083,"owners_count":20330155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","elm","elm-demos","elm-lang","elm-language","example","node","node-js","nodejs","nodejs-server","server","serverless"],"created_at":"2024-09-24T22:45:36.949Z","updated_at":"2026-01-02T06:03:03.372Z","avatar_url":"https://github.com/davidcavazos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elm in Node example\n\n```txt\nℹ️ Elm 0.19\n```\n\nExample to show how to run\n[Elm](https://elm-lang.org/)\ncode in a\n[Node](https://nodejs.org/en/)\napplication.\n\nIt uses\n[Elm ports](https://guide.elm-lang.org/interop/ports.html)\nto communicate between Elm and Javascript.\n\n## Before you begin\n\n### Installing Elm\n\n[Elm](https://elm-lang.org/)\nis usually for front-end development,\nbut since it compiles to Javascript,\nwe want to run it in Node as a backend application.\n\nFollow the official guide to\n[install Elm](https://guide.elm-lang.org/install/elm.html).\nIt's very easy, there are installers/instructions for Mac, Linux and Windows.\n\nThen, check your Elm installation.\n\n```sh\nelm --version\n```\n\n### Installing Node\n\nWe only need\n[Node](https://nodejs.org/en/)\nto run the Javascript app as a server.\n\nFollow the instructions to\n[install nvm](https://github.com/nvm-sh/nvm#installing-and-updating).\n\n```sh\n# Verify you have nvm.\nnvm --version\n\n# Install the latest version of node.\nnvm install node\n\n# Make sure you are pointed to nvm's node version.\nwhich node\n# This could look something like:\n#   /Users/\u003cUSER\u003e/.nvm/versions/node/v14.4.0/bin/node\n```\n\n## Running an example server\n\nTo run a server, we need to compile it with Elm and run it with node.\nDon't worry, Elm is very fast at compiling so it should compile and run almost instantly.\n\n```sh\nelm make src/Main.elm --output example/main.js \u0026\u0026 node example/run.js\n```\n\nHere's a small summary of what's happening:\n\n1. Elm compiles into Javascript to the file [`example/main.js`](example/main.js).\n1. We created the file [`example/run.js`](example/run.js), and we run it with node.\n1. Node imports and loads the compiled Elm application.\n1. First, we print how Elm's ports look like.\n1. Then, we subscribe to an Elm port, and send a message to another port.\n\n\u003e ℹ️ To learn more about Elm/Javascript interoperability, see:\n\u003e\n\u003e https://elm-lang.org/docs/syntax#javascript-interop\n\n---\n\n\u003e \u003cdetails\u003e\n\u003e \u003csummary\u003eClick here to show how the output should look like.\u003c/summary\u003e\n\u003e \n\u003e ```txt\n\u003e \u003e\u003e elm make src/Main.elm --output example/main.js \u0026\u0026 node example/run.js\n\u003e\n\u003e Success!\n\u003e\n\u003e     Main ───\u003e example/main.js\n\u003e\n\u003e Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.\n\u003e {\n\u003e   fromJavascript: { send: [Function: send] },\n\u003e   toJavascript: {\n\u003e     subscribe: [Function: subscribe],\n\u003e     unsubscribe: [Function: unsubscribe]\n\u003e   }\n\u003e }\n\u003e App started\n\u003e From Elm: Tick 1591817413060; Model init\n\u003e From Elm: Tick 1591817414065; Model init\n\u003e From Elm: I received a message, changing the model to: Hello from Node!\n\u003e From Elm: Tick 1591817415068; Model Hello from Node!\n\u003e From Elm: Tick 1591817416069; Model Hello from Node!\n\u003e Done\n\u003e ```\n\u003e\n\u003e \u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcavazos%2Felm-in-node-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidcavazos%2Felm-in-node-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcavazos%2Felm-in-node-example/lists"}