question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

var cwd = process.cwd(); Error: No such file or directory

See original GitHub issue

We are seeing this following behavior often with forever.

When starting an app, the following is logged to the error log over and over again:

 node.js:289
      var cwd = process.cwd();
                  ^
 Error: No such file or directory
      at Function.resolveArgv0 (node.js:289:23)
      at startup (node.js:43:13)
      at node.js:448:3

We are running node 4.1.2 and forever 0.7.5. Forever is instantiated like:

    //Setup spawn child
    var child = new(forever.Monitor)(torqueObject.start, {
        silent: true,
        forever: true,
        watch: false,
        sourceDir: "/nodesocket/gears/" + gear,
        outFile: "/nodesocket/gears/" + gear + "/logs/output.log",
        errFile: "/nodesocket/gears/" + gear + "/logs/error.log",
        logFile: "/nodesocket/gears/" + gear + "/logs/forever.log",
        pidFile: "/etc/nodesocket/lever/pids",
        options: torqueObject.parameters,
        minUptime: 2000,
        spinSleepTime: 1000,
        killTree: true,
        env: torqueObject.env
    });

    //Acutally spawn child
    child.start();

Obviously its trying to get the current working directory, but failing. Any idea what specific code in forever is calling process.cwd().

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:29 (4 by maintainers)

github_iconTop GitHub Comments

190reactions
geoywscommented, Oct 3, 2014

I don’t know if this helps but I ran into this error, then I closed all my terminals and I ran my command “sudo npm cache clean -f” and “sudo npm install -g n” and voila: no more process.cwd problems.

I have an inkling that opened terminals in Vim and in npm folders might be the cause of the error.

173reactions
Marakcommented, Dec 28, 2011

Usually this indicates you are attempting to run a node script in a directory that doesn’t exist on the system.

I’d suggest trying to add some guards before the new forever.Monitor call to ensure that your sourceDir, outFile, errFile, etc, exist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS Error: node.js:810 var cwd = process.cwd()
I got this when created a directory in a git branch, switched to a different branch (without the new directory), and switched back....
Read more >
Ecosystem File - PM2
Advanced process manager for production Node.js applications. Load balancer, logs facility, startup script, micro service management, at a glance.
Read more >
@rollup/plugin-node-resolve - npm
Useful when executing rollup in a package of a mono-repository. // Set the root directory to be the parent folder rootDir: path.join(process.cwd ......
Read more >
Process | Node.js v19.3.0 Documentation
It is possible to record such errors in an error log, either periodically (which ... The process.cwd() method returns the current working directory...
Read more >
ENOENT: no such file or directory when deployed to Vercel
After a lot of Googling I stumbled across a GitHub issue which discussed the fact that it was down the use of process.cwd()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found