Search code examples
coffeescriptpm2

Error running coffee code with pm2: Error: spawn /usr/local/lib/node_modules/pm2/node_modules/.bin/coffee ENOENT


After I upgraded pm2 from 2.1.5 to 3.4.1 I started to get the following error when I try to start/restart an app pm2 restart api:

PM2      | App [api:6] starting in -fork mode-
PM2      | App [api:6] online
PM2      | Error: spawn /usr/local/lib/node_modules/pm2/node_modules/.bin/coffee ENOENT
PM2      |     at Process.ChildProcess._handle.onexit (internal/child_process.js:247:19)
PM2      |     at onErrorNT (internal/child_process.js:431:16)
PM2      |     at processTicksAndRejections (internal/process/task_queues.js:81:17)
PM2      | App [coffee:10] exited with code [0] via signal [SIGINT]

I tried to install coffee for pm2 with pm2 install coffee but it didn't help - I see a lot of this in the pm2 logs:

PM2      | App [coffee:11] exited with code [0] via signal [SIGINT]
PM2      | App [coffee:11] starting in -fork mode-
PM2      | App [coffee:11] online
PM2      | App [coffee:11] exited with code [0] via signal [SIGINT]
PM2      | App [coffee:11] starting in -fork mode-
PM2      | App [coffee:11] online

Solution

  • To install coffeescript version 1 for pm2 run

    pm2 install coffee-script
    

    To install coffeescript version 2 run

    pm2 install coffeescript