Spawn Rscript ENOENT error while running R script in NodeJS - node.js

index.js file
R("message.R")
.data("hello world", 20)
.call(function(err, d) {
if (err) console.log('err:', err);
console.log('hiiii:', d);
});
message.R file
Print('ankit is here')
In command line, when running node index.js, getting error spawn Rscript ENOENT
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn Rscript ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3) Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

If you are also facing the same issues, after spending 4-5 hour time, I get to know that we need to install R in your local machine. the procedure of installing R is as mentioned in the link.install R in ubuntu
After that type R,
you will get R environment
Install
install.packages("dplyr");

Related

Need to run a separate power shell script using nodejs inside my Ubuntu OS

Need to run a separate power shell script using nodejs in my Ubuntu OS
var spawn = require("child_process").spawn,child;
child = spawn("powershell.exe",["file path"]);
Error: spawn powershell.exe ENOENT
at Process.ChildProcess._handle.onexit
(internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain
(internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit
(internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]

Error: spawn ngr ENOENT

I am totally unaware of this kind of error,
whats the causing this error how can I solve it?
cross-env NODE_ENV=development ngr build dev
Console Error.
events.js:165
throw er; // Unhandled 'error' event
^
Error: spawn ngr ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
at onErrorNT (internal/child_process.js:379:16)
at process._tickCallback (internal/process/next_tick.js:114:19)
at Function.Module.runMain (module.js:692:11)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:666:3
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:207:12)
at onErrorNT (internal/child_process.js:379:16)
[... lines matching original stack trace ...]
at bootstrap_node.js:666:3

Error: spawn EPERM and Error: spawn ENOENT

I'm trying to convert a markdown to pdf using the npm package markdown-pdf with the code below of index.js and I'm getting these errors after run node index.js.
The first error I got is on my Windows 10 Host Machine, and the second one is on my Ubuntu Guest VirtualBox VM.
Any idea of how to solve this? Anything related with phantomjs package?
index.js
var markdownpdf = require("markdown-pdf"),
fs = require("fs")
markdownpdf().from("./README.md").to("./curriculo.pdf", function() {
console.log("Converted to PDF successfully!")
})
Terminal Output Error - Windows Host VM
internal/child_process.js:319
throw errnoException(err, 'spawn');
^
Error: spawn EPERM
at exports._errnoException (util.js:1018:11)
at ChildProcess.spawn (internal/child_process.js:319:11)
at exports.spawn (child_process.js:378:9)
at Object.exports.execFile (child_process.js:143:15)
at WriteStream.<anonymous>
(C:\Users\User\Documents\localdev\curriculo\node_modules\markdown-pdf\index.js:117:22)
at emitNone (events.js:91:20)
at WriteStream.emit (events.js:185:7)
at finishMaybe (_stream_writable.js:512:14)
at afterWrite (_stream_writable.js:386:3)
at onwrite (_stream_writable.js:376:7)
Terminal Output Error - Ubuntu Guest VM
stream.js:74
throw er; // Unhandled stream error in penter code hereipe.
^
Error: spawn /media/sf_localdev/curriculo/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:441:9)
at process._tickCallback (node.js:355:17)

react-native init error with nodejs

I got this error when I use command react-native init hello in nodejs
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at exports._errnoException (util.js:855:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:455:9)
at process._tickCallback (node.js:369:17)

Trying to spawn ruby sass from Node

I have script called sassy.js
var spawn = require('child_process').spawn,
rubySass = spawn('sass', ['--watch scss:.tmp/css', '--sourcemap=auto', '--style=expanded', '--unix-newlines']);
which I try to run with node sassy.js
$ node sassy.js
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn sass ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
It's strange because this code works:
var exec = require('child_process').exec,
rubySass = exec('sass --watch scss:.tmp/css --sourcemap=auto --style=expanded --unix-newlines');
I choose spawn beacuse finally I want to return stdout which I could redirect to node package called clean-css by Npm run script
"scripts": {
"build-sass:clean": "node sassy.js |
}
with: npm run build-sass:clean
EDITED
After help from Lovell Fuller I updated sassy.js rubySass = spawn('c:/Ruby21-x64/bin/sass', ['--watch scss:.tmp/css', '--sourcemap=auto', '--style=expanded', '--unix-newlines'])
but node sassy.js stills yelds
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn c:/Ruby21-x64/bin/sass ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
I've tried with c:/Ruby21-x64/bin/sass.batbut despite no errors, there is no output as well :-/
exec uses the shell to run commands and is able to locate and prefix sass with its full path.
spawn does not run commands via the shell so you'll need to provide the full path, e.g. /usr/bin/sass.
If you're unsure what the full path needs to be, the which sass command should provide this.
I don't know if this will be relevant but did you forget a end quotation?
"scripts": {
"build-sass:clean": (--->)"node sassy.js |
}
"scripts": {
"build-sass:clean": "node sassy.js" |
}

Resources