"No Processes Defined" from foreman check on a simple node.js Procfile

Using this example procfile:

web: node app.js

I'm getting errors when running the command

foreman check

The error I'm getting is:

ERROR: no processes defined

Not sure if this matters, but I'm running this on Windows 8. The application runs successively on my local machine running just:

node app.js

Unfortunately, Foreman does not run on Windows. ddollar started up an alternate project, foreman-windows, to try to add Windows support, but I don't know if it ever fully got off the ground.

If you'd like a helper task to start up your node environment locally, writing your own cake task is good, albeit manual, alternative:

{spawn, exec} = require 'child_process'

task 'start', 'Spin up dev environment', ->
  exec 'node app.js'

Then you'd execute the task in the command line:

cake start

This gives you the added benefit of creating multiple tasks for various actions, and fine-tuning the tasks to fit the needs of your project.

Note that Windows likes to switch things up when it comes to certain commands. For instance, on *nix-based machines you could open your site in a browser with:

exec "open http://localhost:3000/"

But on Windows, it is start instead:

exec "start http://localhost:3000/"

Another important difference is handling environment variables. On *nix, you can simply prepend them to your command:

exec "NODE_ENV=staging node server.js"

But if you try to use that format with exec on Windows, it'll fail. Instead, spawn a new bash:

terminal = spawn 'bash'
terminal.stdin.write "NODE_ENV=staging node server.js"
terminal.stdin.end()

And you can listen for events from the bash too:

terminal.stdout.on 'data', (data) ->
  console.log "#{data}"
terminal.stderr.on 'data', (data) ->
  console.log "#{data}"

If you are writing tools that have to support multiple platforms, you can do a OS platform check relatively easily to make accommodations:

os = require 'os'

if os.platform() is 'win32'
  <do Windows stuff>