Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
A Node.js CLI tool for easily running your elm code.
elm init
elm-node --example-elm > src/Main.elm
elm-node src/Main.elm
Warning: This isn't neither a beginner tool, nor the intended default Elm
experience. If you want to experiment, use elm repl
or elm-reactor
. Using
the elm
CLI with --output=index.html
is also a very easy way to try things.
Really evaluate if you want or need node.js. You will need to be familiar and
fluent in both node.js and Elm to make good use of this tool.
npm install -g elm-node
, then make a directory to test it out.
mkdir my-node-project && cd my-node-project
elm init
See the following sections for usage instructions.
You can just create a Main.elm. On the JS side there will be a JS port called
log
that you can use to send String
to output.
You can use --example-elm
to get a very basic Main.elm
to get started:
elm-node --example-elm > src/Main.elm
elm-node src/Main.elm
With the basic setup there is also a port eval
subscribed to on the JS side
that will run the code it receives. On the JS side there is also a global app
variable that you can use in your JS code string to send events back to Elm. Not
the most fancy way to interact with JS, but it gets the job done.
If you want to do something more complex see the custom setup below.
Similar to the previous setup, but you can provide a custom JS file that will get passed the Elm object so that you can init whatever app you want, or set up any ports you need.
The JS file passed, needs to export a function that will get the Elm object from the compiled output. You can do with it as you please.
You can use --example-elm
and --example-js
to get a very basic Main.elm
and custom JS to get started:
elm-node --example-elm > src/Main.elm
elm-node --example-js > src/index.js
elm-node --js src/index.js src/Main.elm
You can pass --optimize
for the compiler to do the optimized build, but it
probably won't get you much in Node.js, except for getting rid of the
development build warning output. The compile times are longer, so maybe just
use it when you are going to ship.
FAQs
Run Elm + JS programs easily in node
We found that elm-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.