I'm new to nodeJS and also new to StackOverflow...
I'm starting to develop my first SPA, using RequireJS to compile my sources into a "dist" folder. I had NodeJS running a basic script to run my server:
var connect = require('connect'); connect.createServer( connect.static(__dirname) ).listen(8080);
Everything was working well, till I compile my src again. That replaced all the files served by my server, so I though I would restart Node. I Ctrl^C and from this moment, I can't get Node to start again. When I try to run:
olivier$ node server.js
I get this error:
node.js:810 var cwd = process.cwd(); ^ Error: ENOENT, no such file or directory at Function.startup.resolveArgv0 (node.js:810:23) at startup (node.js:58:13) at node.js:901:3
What's strange is that I get the same error just trying to start NodeJS, simply doing:
olivier$node
Anyone has an idea of what I can do beside uninstalling Node and reinstalling it ?
I got this when trying to run the Node REPL from a directory I had already deleted (from another shell). Don't let this happen to you or you will be ashamed.
Could it be that RequireJS is also recreating the directory that contains your server.js
?
Try and see if this works:
$ cd $PWD; node server.js
Although it seems useless to change the directory to the current directory, the rationale is that when a directory gets deleted while it's the current working directory of your shell, the shell is left in a dangling state because it's still 'attached' to the previously deleted directory. This also affects any processes that you start from that shell (like Node), and can yield confusing errors.
By executing cd $PWD
, you make sure your shell gets 'reattached' to the newly created version of the directory, solving the dangling state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With