Questions tagged [shelljs]

For questions related to portable implementation of Unix shell commands for Node.js.

ShellJS is a portable (Windows/Linux/OS X) implementation of Unix on top of the

Usage

Install it using

$ npm install -g shelljs

And run scripts

$ shjs your_script_file

See also

82 questions
11
votes
1 answer

how to run node shelljs in sync mode and get stdout and stderr

Within a nodejs script I have the following code which makes the call synchronously and returns the stdout from the shell script I am calling: var sh = require('shelljs'); ... some code var output = sh.exec('./someshellscript.sh',…
CPP
  • 1,031
  • 3
  • 10
  • 26
9
votes
1 answer

webpack + shelljs will throw "Error: Cannot find module '/exec-child.js'"

I want to use shelljs to write some scripts in javascript, since I want to use some new JavaScript features, I use Babel + webpack to bundle my code to a single bundle js. The code is quite simple: entry.js import shell from…
Freewind
  • 193,756
  • 157
  • 432
  • 708
8
votes
2 answers

accessing bull-queue to view job stats from nodejs

I need to access bull-queue to view job stats and show on the page. I'm using bull-repl to access the queue from CLI, as follows: > bull-repl BULL-REPL> connect marathon reddis://localhost:6379 Connected to reddis://localhost:6379, queue:…
Yury Stanev
  • 419
  • 1
  • 5
  • 16
5
votes
1 answer

Set environment variable with shelljs

I'm trying to set an env variable in node with shelljs so here's the psudo code: const shell = require('shelljs'); shell.exec('export MM=2'); shell.exec('echo $MM'); but this does not printout the value of MM Any suggestions on how to set an env…
Mahyar
  • 1,011
  • 2
  • 17
  • 37
5
votes
1 answer

How to suppress errors in shelljs?

When I run the following code in node: var shell = require('shelljs'); var files = shell.ls('-R', './**/foobar'); console.log('Files found:\n' + files.join('\n')); I see this in the output: ls: no such file or directory: ./**/foobar How can I…
Douglas Ludlow
  • 10,754
  • 6
  • 30
  • 54
4
votes
1 answer

shelljs - getting process ID of process created by shelljs.exec() process

So, I'm dealing with an issue on Windows where I can't kill a process spawned using shell.exec(...). I'm creating the process like this: const shell = require('shelljs'); // ... let childProcess = shell.exec('someBinary --whatever', { async: true…
ajcmurray
  • 53
  • 3
3
votes
1 answer

What is the difference between Rimraf and rm -rf through ShellJS

rimraf,The UNIX command rm -rf for node,I think I can do the same thing with rm -rf through shelljs.so what is the diff
lsxjh
  • 31
  • 4
3
votes
1 answer

running shell command through ReactJs code

I have a file stored in local computer and a printer connected too. So generally if I want to give a print of the file to the connected printer, I would run following command in command prompt: cd copy…
Molly
  • 1,887
  • 3
  • 17
  • 34
3
votes
1 answer

Using NPM ShellJS to execute a Git command in Node returns an empty string inside `stdout`

I'm using NPM ShellJS to execute the following Git command inside a Node script: git for-each-ref --sort=v:refname --format "tag: %(refname:strip=2) message: %(subject) date: %(authordate:iso)" refs/tags If I run this command inside a normal command…
shrewdbeans
  • 11,971
  • 23
  • 69
  • 115
3
votes
1 answer

Why do I get a NullReferenceException when using shelljs to clone a git repo?

I am attempting to write a fairly simple nodejs program that needs to clone a git repo. var shell = require('shelljs'); shell.exec('git clone http://mybitbuck.et/scm/myproject/myrepo.git'); Throws an error as follows, and then seems to hang without…
Meg
  • 938
  • 9
  • 20
3
votes
1 answer

Execute shell commands in typescript

Is there a way to execute commands in Typescript, just like we do in Javascript with Shelljs Library?
Celine119
  • 45
  • 1
  • 3
3
votes
1 answer

Execute ssh shell script from npm command

I'm trying to write an npm script that will execute an ssh shell command. Currently it's working by executing an osascript command to open a Terminal window and run the command. I'd like to change this to execute the command in the current…
Ethan22
  • 747
  • 7
  • 25
3
votes
0 answers

shelljs: shx can't work correctly

I am working in windows platform, and want to use some Unix shell command in daily work.So I install the shelljs package via node as following: npm install -g shelljs the installation runs well. But I can't use the shx as interface to run Unix…
Chris Bao
  • 2,418
  • 8
  • 35
  • 62
3
votes
1 answer

Can't resolve module 'child_process'

I have an angular2 webpack project that is running in electron. I'm trying to use shelljs but webpack fails to build with the error: [0] ERROR in ./~/shelljs/src/exec.js [0] Module not found: Error: Can't resolve 'child_process' in…
otoomey
  • 939
  • 1
  • 14
  • 31
3
votes
1 answer

ReferenceError: process is not defined when requiring Shelljs in ReactJS

I am trying to require shelljs in my core React component. import React, { Component } from 'react'; import {render} from 'react-dom'; import Header from './components/Header'; const shell = require('shelljs'); class App extends Component { …
Goamaral
  • 299
  • 2
  • 4
  • 15
1
2 3 4 5 6