Hi there!
I am running the following stack :
pm2 v3.4.0
noded v11.11.0
npm v6.7.0
Running my application while dockerised dies immediately with Cannot find module '../constants.js'
Funny, strace shows this lookup happening:
stat("/usr/src/app/node_modules/.bin", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/usr/src/app/node_modules/constants.js", 0x7ffd94d827c0) = -1 ENOENT (No such file or directory)
stat("/usr/src/app/node_modules/constants.js.js", 0x7ffd94d826f0) = -1 ENOENT (No such file or directory)
stat("/usr/src/app/node_modules/constants.js.json", 0x7ffd94d826f0) = -1 ENOENT (No such file or directory)
stat("/usr/src/app/node_modules/constants.js.node", 0x7ffd94d826f0) = -1 ENOENT (No such file or directory)
mprotect(0x183097484000, 503808, PROT_READ|PROT_WRITE) = 0
For whatever reason pm2 is looking for it's files in root node_modules, as far as I can tell.
So I threw it a bone, cp constants.js node_modules/constants.js and now the error is Cannot find module './paths.js'. So there's no end to this it seems.
I have no explanation for why this may happen in this case and work in others, but I think there may be a legit bug here. Sounds like https://github.com/Unitech/pm2/issues/4001 in a way.
ping @Unitech
how did you installed pm2 and node.js?
I'm having the same issue. It works locally on my mac, but gets the above error when deployed to ec2. Installing with yarn.
@Unitech node comes with my image, node ;)
pm2 - > npm install pm2 -g, the usual.
@arvidboivie hi mate, have you maybe managed to work around this somehow?
@arvidboivie hi mate, have you maybe managed to work around this somehow?
Not really, I went with a systemd solution instead.
@orwell1984 can you show me your image build or share anythin to make me able to reproduce this issue, else I cannot help..
@Unitech You can run docker image phylogenyexplorer/client:0.0.2 if you want to reproduce.
Repo is here - https://github.com/phylogeny-explorer/explorer/
You can run bash in it via docker run -p 3000:3000 -it --entrypoint bash phylogenyexplorer/client:0.0.2
Hi @Unitech , any chance you had time to look into this? I can't do anything about my project because of this issue...
Hi,
You can use directly pm2 start ... instead of npx pm2 start it will work.
root@d6df3b884a84:/usr/src/app# npx pm2 start ecosystem.config.js
Cannot find module '../constants.js'
root@d6df3b884a84:/usr/src/app# pm2 start ecosystem.config.js
[PM2] Applying action restartProcessId on app [admin-front-end](ids: 0)
[PM2] [admin-front-end](0) β
βββββββββββββββββββ¬βββββ¬ββββββββββ¬βββββββ¬ββββββ¬βββββββββ¬ββββββββββ¬βββββββββ¬ββββββ¬ββββββββββββ¬βββββββ¬βββββββββββ
β App name β id β version β mode β pid β status β restart β uptime β cpu β mem β user β watching β
βββββββββββββββββββΌβββββΌββββββββββΌβββββββΌββββββΌβββββββββΌββββββββββΌβββββββββΌββββββΌββββββββββββΌβββββββΌβββββββββββ€
β admin-front-end β 0 β N/A β fork β 104 β online β 1 β 0s β 0% β 22.8 MB β root β disabled β
βββββββββββββββββββ΄βββββ΄ββββββββββ΄βββββββ΄ββββββ΄βββββββββ΄ββββββββββ΄βββββββββ΄ββββββ΄ββββββββββββ΄βββββββ΄βββββββββββ
Use `pm2 show <id|name>` to get more details about an app
@Eywek wow, thanks mate! I did not think to check this way of running.
thanks @Eywek, closing the issue
Hi,
You can use directly
pm2 start ...instead ofnpx pm2 startit will work.root@d6df3b884a84:/usr/src/app# npx pm2 start ecosystem.config.js Cannot find module '../constants.js' root@d6df3b884a84:/usr/src/app# pm2 start ecosystem.config.js [PM2] Applying action restartProcessId on app [admin-front-end](ids: 0) [PM2] [admin-front-end](0) β βββββββββββββββββββ¬βββββ¬ββββββββββ¬βββββββ¬ββββββ¬βββββββββ¬ββββββββββ¬βββββββββ¬ββββββ¬ββββββββββββ¬βββββββ¬βββββββββββ β App name β id β version β mode β pid β status β restart β uptime β cpu β mem β user β watching β βββββββββββββββββββΌβββββΌββββββββββΌβββββββΌββββββΌβββββββββΌββββββββββΌβββββββββΌββββββΌββββββββββββΌβββββββΌβββββββββββ€ β admin-front-end β 0 β N/A β fork β 104 β online β 1 β 0s β 0% β 22.8 MB β root β disabled β βββββββββββββββββββ΄βββββ΄ββββββββββ΄βββββββ΄ββββββ΄βββββββββ΄ββββββββββ΄βββββββββ΄ββββββ΄ββββββββββββ΄βββββββ΄βββββββββββ Use `pm2 show <id|name>` to get more details about an app
npx pm2 startnot workοΌwhyοΌ