Tagged: nodejs

0

Returning a value from a node child process

One can execute Linux, git shell commands from node script using node’s child process API like exec, execSync. But when you want to save the return value outside of the function scope, one must...

0

npm WARN Invalid name:

Have you received below error while doing npm install? npm install npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN Invalid name: Foo Bar Solution: In your package.json, “name”...

0

How to run unix commands from nodejs?

Nodejs allows us to execute linux commands from its child process module as shown below. var exec = require(‘child_process’).exec; // any unix based command var cmdToLaunch = “ls -la”; function execCB (error, stdout, stderr)...

0

xCode: gulp: command not found

If you’re using gulp or similar build tools to build your project you might run into this issue. /Users/username/Library/Developer/Xcode/DerivedData/project/filename.sh: line 4: gulp: command not found Here, xCode can not find gulp because it uses...

0

How to read a file as a string in nodejs javascript?

Below code reads the file content in asynchronous manner and the content is returned in the string format and buffered format respectively. let fs = require(“fs-extra”); let path = require(“path”); fs.readFile(path.join(__dirname, “filePath”), “utf8”,(data, err)...

0

How to run cli/unix commands from nodejs scripts?

There are two ways to do this: child_process.exec(command[, options][, callback]) // ls.js const { exec } = require(‘child_process’); exec(‘ls -lh /usr’, (error, stdout, stderr) => { if (error) { console.error(`exec error: ${error}`); return; }...