logo
down
shadow

How do I debug "Error: spawn ENOENT" on node.js?


How do I debug "Error: spawn ENOENT" on node.js?

By : user2948299
Date : November 14 2020, 04:48 PM
like below fixes the issue NOTE: This error is almost always caused because the command does not exist, because the working directory does not exist, or from a windows-only bug.
I found a particular easy way to get the idea of the root cause of:
code :
Error: spawn ENOENT
(function() {
    var childProcess = require("child_process");
    var oldSpawn = childProcess.spawn;
    function mySpawn() {
        console.log('spawn called');
        console.log(arguments);
        var result = oldSpawn.apply(this, arguments);
        return result;
    }
    childProcess.spawn = mySpawn;
})();
spawn called
{ '0': 'hg',
  '1': [],
  '2':
   { cwd: '/* omitted */',
     env: { IP: '0.0.0.0' },
     args: [] } }


Share : facebook icon twitter icon
Using nodejs's spawn causes "unknown option -- " and "[Error: spawn ENOENT]" errors

Using nodejs's spawn causes "unknown option -- " and "[Error: spawn ENOENT]" errors


By : saheb
Date : March 29 2020, 07:55 AM
I wish did fix the issue. After lots of trying different things, I finally had a look at what "npm" actually is on windows, and it turns out to be a bash script called npm, as well as a windows-native batch script called npm.cmd (no idea why it's .cmd, that should be .bat, but there you have it). Windows's command resolver will see npm, notice that it's not an executable, see npm.cmd, and then notice that IS an executable, and will then use that instead. This is helpful when you're in a terminal, but spawn() will not do any such resolution: passing it npm will make it fail because it's not an executable. Passing it npm.cmd as command, however, works just fine.
(Also, not sure why rm was failing earlier, since that actually works correctly without any changes that I can tell. Probably misread that as part of the problem when in fact it wasn't.)
code :
var npm = (process.platform === "win32" ? "npm.cmd" : "npm"),
    child = spawn(npm, ["install", ...]);
...
Node.js spawn/exec/execFile/win-spawn/cross-spawn all throwing Error: spawn ENOENT

Node.js spawn/exec/execFile/win-spawn/cross-spawn all throwing Error: spawn ENOENT


By : Tom Fredrickson
Date : March 29 2020, 07:55 AM
Hope that helps Where win-spawn and cross-spawn failed, spawn-cmd worked.
I have no idea why cross-spawn didn't work when spawn-cmd did, as they're pretty similar, but there you go. As to the original problem, I guess it's an issue with node.
running NodeJs script from WebStorm gives "spawn cmd.exe ENOENT" error

running NodeJs script from WebStorm gives "spawn cmd.exe ENOENT" error


By : Skyus
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , The cmd.exe file is located under the c:\windows\system32 folder.
The shortcut %system32% can be used within environment settings.
"Error: spawn mongoexport ENOENT" when running dockerized node app

"Error: spawn mongoexport ENOENT" when running dockerized node app


By : Milo Cao
Date : March 29 2020, 07:55 AM
hope this fix your issue As I have rightly guessed, the issue is that 'mongodb' was not installed in the nodeapp container.
All I had to do was add the following lines in the Dockerfile to install mongodb in nodeapp container
code :
RUN apt-get update 
RUN apt-get install -y mongodb
var mongoExport = spawn('mongoexport', [
                 '--db', 'dbname', '--host', 'mongo-rnd', '--port', 27017, '--collection', 'collection1','--fields', 'name,address,city,country,pincode',
                 '--csv']);
"Error: spawn git ENOENT" when running react-scripts test

"Error: spawn git ENOENT" when running react-scripts test


By : Bruco
Date : March 29 2020, 07:55 AM
will be helpful for those in need I eventually figured out what was causing this. Something about my local setup is causing an error when git is launched as part of the Jest watcher (still not clear what). From the create-react-app docs:
Related Posts Related Posts :
  • How to ignore libraries in browserify programmatic api
  • Node/Express/Jade style guides?
  • how do I return data from a node.js request call? (undefined is not a function)
  • res.sendfile() doesn't serve javascripts well
  • File path completion relative to the current file directory
  • Tuning node-mongodb-native connection pool size
  • Express Socket.io example server not working
  • node js can't install right on my Ubuntu computer
  • How can i do an "or" query in a Model.find on Sails?
  • Confused in starting a project in node.js with npm install
  • unit testing express route with async callback
  • Mongoose sum operation in collection
  • document save function not working in mongoose
  • Why is the zlib inflate function is not working in correct order in node.js?
  • Nested if inside each (Handlebars template in Express app)
  • How does the cookie-session middleware work in expressjs?
  • grunt-processhtml remove not working when specifying a target
  • Error: CERT_HAS_EXPIRED in Node.js request module (macu vs facebook)
  • Async web requests are making 'socket hangup' in node.js
  • ExpressJS: Middleware control flow for Router.param() & Router.use()
  • Glob recursive/zero or more directories, excluding directories
  • node.js v0.11.14 as service with --harmony
  • Running npm install from Sublime Text 2 doesn't work
  • update on a subdoc with mongoose
  • NodeJS Aerospike UDF execute memory leak
  • Alternative to path module that always uses forward-slashes?
  • How do you stream a csv file into a node web app?
  • How to modularize routing with Node.js Express
  • NodeJS - Modularising SQLite3
  • MongoDB / Node: Incorrect Arguments
  • How to use Aggregate in mongoose
  • How to generate multiple reports with mocha?
  • AWS Lambda making video thumbnails
  • MEAN stack on Ubuntu 14.04 suddenly stopped working
  • node.js/express/mongoose noob issue
  • Nodejs ssh convert output byte stream to a sliceable string
  • different behavior of process.argv
  • How to expose the Application model's register method
  • How to install FFMPEG on Node/Meteor server?
  • How Can I Use vhost to Redirect a Sub-Domain to an ExpressJS Route?
  • Gmail API not respecting UTF encoding in subject
  • installing Node modules on Docker: why are they disappearing?
  • How do I set up Node/Express to act as a STUN server?
  • What is the Linear Execution Model in Meteor?
  • connect-redis and express-session results in req.session undefined
  • Application Error Heroku - Problems with Deployment
  • How to pass node v8 args and script args to pm2?
  • Can it be necessary to require a module (child_process in this case) more than once?
  • Too many bad command: outbound emails with Haraka
  • what does require("child_process") actually do?
  • How can I list all my Amazon EC2 instances using Node.js in AWS Lambda?
  • Passing param to custom middleware
  • Proper way to combine route and api auth using loopback.js
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org