Simple commandline interface to allow you to run cli or bash style commands as if you were in the terminal.
Installations
npm install node-cmd
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=6.4.0
Node Version
14.17.1
NPM Version
6.14.13
Score
97.5
Supply Chain
98.2
Quality
78.1
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
RIAEvangelist
Download Statistics
Total Downloads
12,928,701
Last Day
5,576
Last Week
32,100
Last Month
136,575
Last Year
1,421,990
GitHub Statistics
285 Stars
50 Commits
31 Forks
7 Watching
2 Branches
6 Contributors
Bundle Size
455.00 B
Minified
267.00 B
Minified + Gzipped
Package Meta Information
Latest Version
5.0.0
Package Id
node-cmd@5.0.0
Size
2.75 kB
NPM Version
6.14.13
Node Version
14.17.1
Publised On
29 Jul 2021
Total Downloads
Cumulative downloads
Total Downloads
12,928,701
Last day
-10.9%
5,576
Compared to previous day
Last week
17.5%
32,100
Compared to previous week
Last month
30.6%
136,575
Compared to previous month
Last year
-29.3%
1,421,990
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No dependencies detected.
node-cmd
Node.js commandline/terminal interface.
Simple commandline, terminal, or shell interface to allow you to run cli or bash style commands as if you were in the terminal.
Run commands asynchronously, and if needed can get the output as a string.
NPM Stats
npm info :
See npm trends and stats for node-cmd
GitHub info :
Package details websites :
- GitHub.io site. A prettier version of this site.
- NPM Module. The npm page for the node-cmd module.
This work is licenced via the MIT Licence.
Methods
method | arguments | functionality | returns |
---|---|---|---|
run | command, callback | runs a command asynchronously | args for callback err ,data ,stderr |
runSync | command | runs a command synchronously | obj {err ,data ,stderr } |
Examples
1 2//*nix 3 4 var cmd=require('node-cmd'); 5 6//*nix supports multiline commands 7 8 cmd.runSync('touch ./example/example.created.file'); 9 10 cmd.run( 11 `cd ./example 12ls`, 13 function(err, data, stderr){ 14 console.log('examples dir now contains the example file along with : ',data) 15 } 16 ); 17
1 2//Windows 3 4 var cmd=require('node-cmd'); 5 6//Windows multiline commands are not guaranteed to work try condensing to a single line. 7 8 const syncDir=cmd.runSync('cd ./example & dir'); 9 10 console.log(` 11 12 Sync Err ${syncDir.err} 13 14 Sync stderr: ${syncDir.stderr} 15 16 Sync Data ${syncDir.data} 17 18 `); 19 20 cmd.run(`dir`, 21 function(err, data, stderr){ 22 console.log('the node-cmd dir contains : ',data) 23 } 24 ); 25
1 2//clone this repo! 3 4 var cmd=require('node-cmd'); 5 6 const syncClone=cmd.runSync('git clone https://github.com/RIAEvangelist/node-cmd.git'); 7 8 console.log(syncClone); 9
Getting the CMD Process ID
1 2 var cmd=require('node-cmd'); 3 4 var process=cmd.run('node'); 5 console.log(process.pid); 6
Running a python shell from node
1const cmd=require('node-cmd'); 2 3const processRef=cmd.run('python -i'); 4let data_line = ''; 5 6//listen to the python terminal output 7processRef.stdout.on( 8 'data', 9 function(data) { 10 data_line += data; 11 if (data_line[data_line.length-1] == '\n') { 12 console.log(data_line); 13 } 14 } 15); 16 17const pythonTerminalInput=`primes = [2, 3, 5, 7] 18for prime in primes: 19 print(prime) 20 21`; 22 23//show what we are doing 24console.log(`>>>${pythonTerminalInput}`); 25 26//send it to the open python terminal 27processRef.stdin.write(pythonTerminalInput); 28
Output :
1 2>>>primes = [2, 3, 5, 7] 3for prime in primes: 4 print(prime) 5 6 72 83 95 107 11 12
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: licence:0
- Info: FSF or OSI recognized license: MIT License: licence:0
Reason
Found 6/21 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Score
3.3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More