I got this error using jshint through a python subprocess on Ubuntu 12.10 64 bit.
node.js:464
var cwd = process.cwd();
^
Error: ENOENT, no such file or directory
at Function.resolveArgv0 (node.js:464:23)
at startup (node.js:51:13)
at node.js:555:3
It is caused because you deleted or moved a directory out from underneath it and the current directory can't be determined.
How to tell if you are having this problem:
Run the command cd .
(If you get this error then you have this problem).
el@apollo:~/foo$ cd .
cd: error retrieving current directory: getcwd: cannot access parent
directories: No such file or director
You tried to change directory into your current dir, and could not.
How to reproduce the error:
jshint is affected by this error. Make a directory foo
, cd into it, make a file called myjavascript.js
cd /home/el
mkdir foo
cd foo
touch myjavascript.js
jshint myjavascript.js
jshint runs correctly, it says there are no errors which is correct.
Open a 2nd terminal, and rm -rf
the directory /home/el/foo
out from underneath.
rm -rf /home/el/foo
Run the jshint myjavascript.js
again from your first terminal and you get an error:
el@apollo:~/foo$ jshint myjavascript.js
node.js:464
var cwd = process.cwd();
^
Error: ENOENT, no such file or directory
at Function.resolveArgv0 (node.js:464:23)
at startup (node.js:51:13)
at node.js:555:3
The directory is gone! And even if you were to replace it with the same contents, it has a different signature and the terminal can't recover, the method getcwd
can't know what the current directory is.
Three Solutions:
The terminal is confused about what the current directory is because its gone or it's signature has changed. Do one of these to fix it:
Run the command cd ..
until you stop getting errors. This re synchronizes the terminal with the filesystem. Then cd back into your directory. Try again. The error goes away.
Use su youruser
in the terminal, enter the password. It refreshes and brings you back to the same directory.
Close and reopen the terminal which flushes away the stale directory signatures. Or send a nastymail to whatever program (jshint) or the thousands of other programs which can't tolerate or recover from stale directory signatures.
cd [PATH]
in your shell to go to an existing one.