Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm2 not working on ubuntu, error "no such file or directory" #455

Closed
leabdalla opened this issue May 10, 2014 · 35 comments
Closed

pm2 not working on ubuntu, error "no such file or directory" #455

leabdalla opened this issue May 10, 2014 · 35 comments

Comments

@leabdalla
Copy link

I'm deploying my project using git and when I try to init, I get:

root@server:/var/dir/myapp# NODE_ENV=production pm2 start myapp.js

node.js:815
    var cwd = process.cwd();
                  ^
Error: ENOENT, no such file or directory
    at Function.startup.resolveArgv0 (node.js:815:23)
    at startup (node.js:58:13)
    at node.js:906:3

In the same dir, if I run ls -la I can see all project files. It works fine with forever or nodemon. What can be happening?

@leabdalla leabdalla changed the title pm2 not working, error "no such file or directory" pm2 not working on ubuntu, error "no such file or directory" May 10, 2014
@Unitech
Copy link
Owner

Unitech commented May 15, 2014

Did you solved it ?

@leabdalla
Copy link
Author

No :(

@Unitech
Copy link
Owner

Unitech commented May 15, 2014

Can you try

NODE_ENV=production pm2 start myapp.js -x

?

$ echo $HOME $PWD

@gratex
Copy link

gratex commented May 22, 2014

We had same issue, and it seems to be solved after changing our deployment script.

We have been deleting the whole directory before copying new version. Now we delete only the content of this directory; copy new version of app and run pm2 gracefulReload

@lcranf
Copy link

lcranf commented May 22, 2014

Can pm2 survive deleting then re-adding all file contents from a directory it is watching and then safely reload? Or would I need to do this everytime (the above didn't work for me):

$ pm2 dump & pm2 kill & pm2 resurrect 

@Unitech
Copy link
Owner

Unitech commented May 23, 2014

@gratex @lcranf #480

@tjwebb
Copy link

tjwebb commented Jun 4, 2014

Also having this issue.

@soyuka
Copy link
Collaborator

soyuka commented Jun 21, 2014

give us data to reproduce please.

@tjwebb
Copy link

tjwebb commented Jun 21, 2014

I've switched to forever, so I'm no longer in a position to reproduce
this issue.

On Sat, Jun 21, 2014 at 10:44 AM, soyuka notifications@github.com wrote:

give us data to reproduce please.


Reply to this email directly or view it on GitHub
#455 (comment).

@Unitech Unitech closed this as completed Jul 2, 2014
@smartmouse
Copy link

Hi: I run into this error too with node.js 10.30.
I do not think this is really PM2 issue.

It may be the system is so busy and somehow things starts to fail. (no process can be spawned).
How I got this error is just by issuing the following on the command line

myaccount@jmyhost:~/node_modules/pm2$ node -e "console.log(process.config)"

node.js:815
var cwd = process.cwd();
^
Error: ENOENT, no such file or directory
at Function.startup.resolveArgv0 (node.js:815:23)
at startup (node.js:58:13)
at node.js:906:3
nodebot@jtcjs01:~/node_modules/pm2$

@rlidwka
Copy link
Collaborator

rlidwka commented Aug 8, 2014

@smartmouse
Copy link

Yes, this is exactly the issue. Thank you.

@gen4sp
Copy link

gen4sp commented Aug 24, 2014

same issue?
right after switch from 0.9.1 to 0.9.4
no other changes happens. rollback to 091 fix issue

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:988:11)
    at Process.ChildProcess._handle.onexit (child_process.js:779:34)

@RomanMinkin
Copy link

Have the same issue, rolling back to v0.9.1 helps, thanks @gen4sp !

@gen4sp
Copy link

gen4sp commented Aug 29, 2014

any updates?

@wmbutler
Copy link

I have this issue as well. My script runs fine when using node directly. Running node v0.10.31.

Linux PDF001 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Running the latest pm2

# pm2 -v
0.10.8

@ejames17
Copy link

ejames17 commented Apr 5, 2015

im having the same issue has anyone resolved this?

@komocode
Copy link

Installing nodejs through apt-get causes this problem since the binary is renamed from node -> nodejs.

@ejames17
Copy link

I figures it out . My issue was the econsystem5.json needs to be in the project root folder

@Jeronimo95
Copy link

For anyone still having this issue: it seems to be because apt-get installs the node binary as 'nodejs' and pm2 is looking for 'node'. Linking node to nodejs solved the issue for me.

ln -s /usr/bin/nodejs /usr/bin/node

@ejames17
Copy link

What's your config file ?

@ejames17
Copy link

Correct you need to sym link nodejs to node

Sent from my iPhone

On May 22, 2015, at 10:33 PM, Jeremy Ryan notifications@github.com wrote:

For anyone still having this issue: it seems to be because apt-get installs the node binary as 'nodejs' and pm2 is looking for 'node'. Linking node to nodejs solved the issue for me.

ln -s /usr/bin/nodejs /usr/bin/node

Reply to this email directly or view it on GitHub.

@Jeronimo95
Copy link

Config file!? What config file? I just pm2 start app.js got the error, so linked nodejs to node...

@ejames17
Copy link

I'm not in front of my machine but there is a ecosystem5.js file you can set the cwd I had the same problem

@Alex0007
Copy link

Alex0007 commented Feb 5, 2016

in ecosystem.json change
"path": "emailcreator",
to
"path": "~/emailcreator",

@erperejildo
Copy link

erperejildo commented Apr 20, 2017

So... what's the solution? Tried everything but still failing.

Trying to deploy a Meteor app

@WebBusinessGeek
Copy link

Anyone found the solution???

@WebBusinessGeek
Copy link

WebBusinessGeek commented May 10, 2017

Hope this helps someone else. Try starting pm2 from a different directory. I was starting my script from my /home/ directory on the system. But navigating to the root directory of my project and THEN starting script seemed to fix the issue.

@LeeJim
Copy link

LeeJim commented Jul 10, 2017

I ran into this issue too. ** It finally worked after run ** pm2 update

@haganbt
Copy link

haganbt commented Jul 22, 2018

Same issue:

Error: ENOENT: no such file or directory, open './config/production.json'

@Unitech
Copy link
Owner

Unitech commented Jul 23, 2018

Error: ENOENT: no such file or directory, open './config/production.json'
Can you run console.log(process.cwd(), __dirname)

@haganbt
Copy link

haganbt commented Jul 23, 2018

@Unitech - thanks for the reply. I added the debug and on the instance where I get the error, the paths are different.

Some additional context, I have 3 services managed by PM2, one of which fails to start (word2vec):

{
  "apps": [
    {
      "name": "crawler",
      "cwd": "/home/ubuntu/crawler/",
      "script": "./app.js",
      "exec_interpreter": "node",
      "merge_logs": true,
      "node_args": "--max_old_space_size=3072",
      "env": {
        "NODE_ENV": "production"
      }
    },
    {
      "name": "build",
      "cwd": "/home/ubuntu/crawler/",
      "script": "./build.js",
      "exec_interpreter": "node",
      "merge_logs": true,
      "node_args": "--max_old_space_size=1024",
      "env": {
        "NODE_ENV": "production"
      }
    },
    {
      "name": "word2vec",    <-- errors
      "cwd": "/home/ubuntu/w2v/",
      "script": "./bin/app.js",
      "exec_interpreter": "node",
      "merge_logs": true,
      "node_args": "--max_old_space_size=2048",
      "env": {
        "NODE_ENV": "production"
      }
    }
  ]
}

My pm2.json file lives under /home/ubuntu/crawler/ directory. The services within this dir start fine (thats "crawler" and "build". Its the third service word2vec that is failing, and as per the config, that lives in another directory.

As per the error, the word2vec service uses a config file and the path is invalid:

Error: ENOENT: no such file or directory, open './config/production.json'

Running the debug as you suggested from the word2vec service yields:

/home/ubuntu/w2v/bin /home/ubuntu/w2v/config

The code that loads the config file (nothing to do with PM2 config) is as follows:

config.loadFile("./config/" + env + ".json");

Appreciate any thoughts or guidance.

@Unitech
Copy link
Owner

Unitech commented Jul 24, 2018

I guess that config.loadFile("../config/" + env + ".json"); will fix the issue, if this code line is in a file in the folder /home/ubuntu/w2v/bin or /home/ubuntu/w2v/config you have to add ..

@haganbt
Copy link

haganbt commented Jul 24, 2018

@Unitech - thanks for the suggestion. Yes, I tried that (along with many other options) however it still fails. I wont pollute this thread further but will report back here once I find the solution.

@haganbt
Copy link

haganbt commented Jul 26, 2018

For anyone else in a similar position, this was finally resolved (after many many hours!) by simply running:

pm2 delete all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests