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" |
}
Related
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");
I installed nodejs and after then when I try to run my previous react app by running yarn start it gives me an error something like this.
Even if I make a new app with create-react-app it gives the same error while trying to start.
nodejs apps are working fine so I think the problem is with create-react-app. I don't know how to fix them.
$ react-scripts start
Starting the development server...
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn cmd 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)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
And I have no idea what is wrong. Please help me fix this.
Change react-scripts version in package.json to 2.1.8. It works for me.
I am getting the below error whenever I run nodemon app.js. I have Node.js 7.4.0 and npm 4.1.2 already installed globally and nodemon 6.7.0 as well. If I run my application using command "node" it works fine but if I use command "nodemon" it throws this error.
I tried to uninstall and re-install nodemon but wtih no difference.
The path for npm has been already added to system variables and "C:\Windows\System32" has been added to both user and system variables.
Any kind of help is highly appreciated.
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
I do understand the difference of concept between .exec and .spawn.
I am trying to run a simple command, lets say echo.
With .exec, the command does work as expected.
With .spawn I receive Error: spawn echo ENOENT.
What am I doing incorrectly?
// WORKS AS EXEPCTED
const exec= require('child_process').exec;
exec("echo hello", function(err, stdout) {
console.log(stdout);
});
// THROWS
const spawn = require('child_process').spawn;
spawn("echo", ["hello"]); // fail
Error received :
Error: spawn echo ENOENT
at exports._errnoException (util.js:1026:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
I am running on Windows!
Thanks for your help and patience.
I finally find the answer to my question.
The problem is that the spawn implementation on Windows can only start executables.
To avoid this problem, you can use win-spawn.
With the help gulp yeoman-webapp 'im wolf. But it also serves on the command line, I get the following error gulp. Can you help me? Thank you in advance.
I work in Windows 10 and 64 bit computing.
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn cmd 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)
Try to put in your system variables in the PATH :
C:\Windows\System32;