npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elm-node

v1.1.6

Published

Run Elm + JS programs easily in node

Downloads

35

Readme

elm-node

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.

Usage

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.

Simple setup, no JS

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

Running arbitrary JS

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.

Custom JS setup

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

Flags

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.