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

Process.chdir() on Centos 7 #1355

Closed
riccardopirani opened this issue Jun 25, 2018 · 7 comments
Closed

Process.chdir() on Centos 7 #1355

riccardopirani opened this issue Jun 25, 2018 · 7 comments

Comments

@riccardopirani
Copy link

  • Node.js Version: v8.11.3
  • OS Centos 7
  • Scope runtime with cron:

Hello then I state that something very strange happens to me, which had never happened to me. So I have a node.js application that runs perfectly on a centos server! Once the application has been loaded on the server, boot with node server.js and everything is working on perfection! As a reboot I set a cron to start the server node with this syntax: @reboot node /var/www/html/app/main.js, the problem is that when I restart the machine the cron starts correctly node.js but when I have to do the change of directory below I have this error:

Node.js Code:

process.chdir('./Model');

Directory Tree:

/var/www/html/app

/var/www/html/app/main.js

/var/www/html/app/Model
@addaleax
Copy link
Member

Can you show the error message? Does it help when you change process.chdir('./Model') to process.chdir(__dirname + '/Model')?

@riccardopirani
Copy link
Author

This is error message: ENOENT: no such file or directory, uv_chdir

@addaleax
Copy link
Member

Okay, can you add console.log(process.cwd()) before and/or try the other suggestion above?

@riccardopirani
Copy link
Author

@addaleax I tried printing me this: /var/www/html/app. I tried your suggestion from before but I always have the same error!

@addaleax
Copy link
Member

What does ls -l /var/www/html/app/Model print on the command line? Maybe the directory doesn’t actually exist?

@riccardopirani
Copy link
Author

this is print of directory:


totale 204
-rw-r--r-- 1 root root  4902 25 giu 16.44 ArticoloModel.js
-rw-r--r-- 1 root root  6199 25 giu 16.44 CantiereModel.js
-rw-r--r-- 1 root root   909 25 giu 16.44 ClienteModel.js
-rw-r--r-- 1 root root 26313 25 giu 17.03 firmacliente.jpg
-rw-r--r-- 1 root root  3467 25 giu 16.44 KilometriModel.js
-rw-r--r-- 1 root root 52834 25 giu 16.44 logo.jpg
-rw-r--r-- 1 root root  7318 25 giu 16.44 RapportiniModel.js
-rw-r--r-- 1 root root 75795 25 giu 17.03 rapportino.pdf
-rw-r--r-- 1 root root  1427 25 giu 16.44 report.rb
-rw-r--r-- 1 root root  4626 25 giu 16.44 RisorseModel.js
-rw-r--r-- 1 root root   845 25 giu 16.44 UserModel.js

@riccardopirani
Copy link
Author

riccardopirani commented Jun 25, 2018

@addaleax i have fix with change cron into: @reboot cd /var/www/html/app/ && node main.js , Thanks for your help

addaleax added a commit to addaleax/node that referenced this issue Jun 25, 2018
Include the current working directory in the error
message for a failing `process.chdir()` since that is
usually information relevant for debugging.

This is semver-major because it moves properties
of the error message object.

Inspired by nodejs/help#1355.
addaleax added a commit to nodejs/node that referenced this issue Jul 17, 2018
Include the current working directory in the error
message for a failing `process.chdir()` since that is
usually information relevant for debugging.

This is semver-major because it moves properties
of the error message object.

Inspired by nodejs/help#1355.

PR-URL: #21526
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants