I'm not sure if my issue is the same as #2742 since I only get the error when using pm2 in package.json.
I have this script in my package.json:
"start": "pm2 start src/server.ts --watch"
and when I
yarn start
I get the error
Interpreter /home/.../.bin/ts-node does not seem to be available
and the process status is 'errored'.
But when I run the pm2 command in the shell it works fine.
===============================================================================
--- PM2 REPORT (Sun Dec 03 2017 13:33:33 GMT+0100 (CET)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 2.8.0
node version : 8.8.1
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : greg
uid : 1000
gid : 100
uptime : 1min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 2.8.0
node version : 8.8.1
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/bin/pm2,report
argv0 : node
user : greg
uid : 1000
gid : 100
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
cpus nb : 4
freemem : 3863879680
totalmem : 8255234048
home : /home/greg
===============================================================================
--- PM2 list -----------------------------------------------
โโโโโโโโโโโโฌโโโโโฌโโโโโโโฌโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโฌโโโโโโฌโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโ
โ App name โ id โ mode โ pid โ status โ restart โ uptime โ cpu โ mem โ user โ watching โ
โโโโโโโโโโโโผโโโโโผโโโโโโโผโโโโโโผโโโโโโโโโโผโโโโโโโโโโผโโโโโโโโโผโโโโโโผโโโโโโโโโผโโโโโโโผโโโโโโโโโโโค
โ server โ 0 โ fork โ N/A โ errored โ 0 โ 0 โ 0% โ 0 B โ greg โ enabled โ
โโโโโโโโโโโโดโโโโโดโโโโโโโดโโโโโโดโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโดโโโโโโดโโโโโโโโโดโโโโโโโดโโโโโโโโโโโ
===============================================================================
--- Daemon logs --------------------------------------------
/home/greg/.pm2/pm2.log last 20 lines:
PM2 | 2017-12-03 13:32:24: [Watch] Start watching server
PM2 | 2017-12-03 13:32:24: Starting execution sequence in -fork mode- for app name:server id:0
PM2 | 2017-12-03 13:32:24: App name:server id:0 online
PM2 | 2017-12-03 13:32:24: Error: spawn /home/greg/Documents/pm2-bug/node_modules/pm2/node_modules/.bin/ts-node ENOENT
PM2 | at _errnoException (util.js:1024:11)
PM2 | at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
PM2 | at onErrorNT (internal/child_process.js:374:16)
PM2 | at _combinedTickCallback (internal/process/next_tick.js:138:11)
PM2 | at process._tickDomainCallback (internal/process/next_tick.js:218:9)
I was facing exact same error. Problem was confusion between global pm2 with local pm2 installed in node_modules of my project. So I had to do
./node_modules/.bin/pm2 install typescript and NOT pm2 install typescript to solve it.
Also that involves using ./node_modules/.bin/pm2 start src/server.ts --watch in your start script in package.json.
Thanks, it works !
I added the script "postinstall": "$(yarn bin)/pm2 install typecsript" to my package.json
@verdie-g Small mistake on your command.
Use:
"postinstall": "$(yarn bin)/pm2 install typescript"
I have an issue trying to install typescript for pm2. This is what I get:
# pm2 install typescript
[PM2][Module] Adding dependency typescript to PM2 Runtime
[PM2][Module] Calling [NPM] to install typescript ...
[PM2][Module] Calling [NPM] to install ts-node@latest ...
โ โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
npm ERR! Linux 4.15.0-50-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "ts-node@latest" "--loglevel=error"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! Cannot read property 'target' of null
npm ERR!
npm ERR! If you need help, you may report this error at:
loadDep:has-values โ โขโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/lib/node_modules/pm2/npm-debug.log
npm ERR! Linux 4.15.0-50-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "typescript" "--loglevel=error"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! Cannot read property 'target' of null
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/lib/node_modules/pm2/npm-debug.log
you can refer to https://pm2.keymetrics.io/docs/tutorials/using-transpilers-with-pm2, it works for me
I've configured pm2 at the machine level and with configuration and I can't use the application node_modules pm2.
I fixed by removing all the pm2 and ts-node from the package.json and make sure you don't run the below commands again and again
sudo pm2 install typescript
sudo pm2 install @types/node
More than once, verify by checking if /usr/lib/node_modules/pm2/node_modules/.bin is having ts-node, if it exist don't install typescript and @types/node.
Freaking annoying issue. It's still there in 2020.
@akopchinskiy try to above solution, I've spent 3 days to figure this solution out.
Most helpful comment
I was facing exact same error. Problem was confusion between global pm2 with local pm2 installed in node_modules of my project. So I had to do
./node_modules/.bin/pm2 install typescriptand NOTpm2 install typescriptto solve it.Also that involves using
./node_modules/.bin/pm2 start src/server.ts --watchin your start script in package.json.