fs.unlink EBUSY error - node.js

I am trying to delete a file in nodejs. When I run the following code:
try {
fs.unlinkSync('file');
} catch(e) {
console.log(e)
}
I get the following error.
Error: EBUSY: resource busy or locked, unlink '<redacted>'
at Object.fs.unlinkSync (fs.js:1067:18)
at Function.rimrafSync [as sync] (<redacted>\node_modules\rimraf\rimraf.js:306:17)
at <redacted>:74:10
at Array.forEach (<anonymous>)
at Function.module.exports.sync (<redacted>\node_modules\node-delete\index.js:67:30)
at <filepath>:4145:46
at Array.forEach (<anonymous>)
at <redacted>:4142:21
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
errno: -4082,
code: 'EBUSY',
syscall: 'unlink',
path: '<redacted>'

This error means the file you're trying to delete is currently in use or locked.

Without providing more informations we will guess, that the file you are trying to delete is locked by another program. Please check this...

Related

What is node:internal/process/promises:279 coming from sails lift

I'm trying to launch sails lift on my back end on vs code and I keep getting this error. I want to know what it means and how to debug it.
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
Error: write EPROTO 140704339895488:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
errno: -100,
code: 'EPROTO',
syscall: 'write'
}
I had to update my node from 16 to 19 and thought that would fix the problem but nothing changed.

Using laravel browsershot

I installed Browsershot and I'm taking google's image to test it. I prepared the route but it gives an unexpected error.
Symfony\Component\Process\Exception\ProcessFailedException
The command "C:^\nodejs^\node ^"C:^\Users^\AT08877^\it-graph^\vendor^\spatie^\browsershot^\src/../bin/browser.js^" ^"^{^^"url^^":^^"http:^/^/127.0.0.1:8000^/chart^^",^^"action^^":^^"screenshot^^",^^"options^^":^{^^"type^^":^^"png^^",^^"path^^":^^"C:^^\Users^^\AT08877^^\it-graph^^\public^^\deneme.png^^",^^"args^^":^[^],^^"viewport^^":^{^^"width^^":800,^^"height^^":600^}^}^}^"" failed. Exit Code: 1(General error) Working directory: C:\Users\AT08877\it-graph\public Output: ================ Error Output: ================ [Error: ENOENT: no such file or directory, mkdtemp 'undefined\temp\puppeteer_dev_chrome_profile-XXXXXX'] { errno: -4058, code: 'ENOENT', syscall: 'mkdtemp', path: 'undefined\temp\puppeteer_dev_chrome_profile-XXXXXX' }
Route::get('/test',function ()
{
$browser = Browsershot::url('www.google.com')
->setNodeBinary("'C:\Program Files\nodejs\node'")
->setNpmBinary("'C:\Program Files\nodejs\node'")
->bodyHtml();
dd($browser);
});

ERROR when compile using Nodejs webpack compile:scss error

i have the following error when run this npm run compile:js i get this error:
> sfra#6.0.0 compile:scss
> sgmf-scripts --compile css
C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\webpack\lib\ChunkGraph.js:1679
throw new Error(
^
Error: Chunk.getNumberOfModulesThere was no ChunkGraph assigned to the Chunk for backward-compat (Use the new API)
at deprecated (node:internal/util:89:15)
at Function.getChunkGraphForChunk (C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\webpack\lib\ChunkGraph.js:1689:10)
at Chunk.getNumberOfModules (C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\webpack\lib\Chunk.js:170:21)
at ExtractTextPlugin.<anonymous> (C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\extract-text-webpack-plugin\dist\index.js:302:30)
at Array.forEach (<anonymous>)
at C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\extract-text-webpack-plugin\dist\index.js:301:25
at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\sgmf-scripts\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
at AsyncSeriesHook.lazyCompileHook (C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\sgmf-scripts\node_modules\tapable\lib\Hook.js:154:20)
at C:\Users\Administrator\Desktop\NewTry\trainingb2c\node_modules\sgmf-scripts\node_modules\webpack\lib\Compilation.js:1405:32
this is my webpack.config.js:
webpack.config.js
Some idea to solve? thanks in advance

How to get PostgreSQL dump database file using Node JS

I tried to generate postgresql dump file using Node JS. SO, I used secure-backup library to generate pg-dump file encrypted. I add this package in my project and I configured .pem file also. When I execute this file it's throwing some error. but I couldn't understand what type error is throwing and how to fix it I don't know. Any one give some suggestion how to resolve this issue to generate pg dump file using Node JS otherwise different library used to generate pg dump file.
CODE
let secureBackup = require('secure-backup');
let pgHandler = require('secure-backup/lib/handlers/pg')
console.log('hi')
let backup = secureBackup({
pubKeyPath: 'C:/Users/DELL/Desktop/Twilio_Phone/cert.pem', // path to your public key
outputPath: 'C:/Users/DELL/Desktop/DB_Dump', // where to output your encrypted backup
compress: true, // enable compression (gzip)
handler: pgHandler({
user: 'postgres',
password: '*****',
database: '****'
})
})
backup() // can be invoked directly
// or used with a cron-job module like node-schedule
Error
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn pg_dump ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn pg_dump',
path: 'pg_dump',
spawnargs: [ '-U', 'postgres', 'HP', 'hummapi' ]
}

Hazelcast Nodejs Client Connection Refused

I am trying to run the basic example code provided in the "Using the Client" section of https://github.com/hazelcast/hazelcast-nodejs-client
I am getting a connection refused error. I tried this on both my Mac and my PC machines with the same result. They are running Node v6.9.1. I do not have any special firewall settings. Even tried turning of the Windows firewall completely.
Is there something I am missing?
[DefaultLogger] WARN at ClientConnection: Could not connect to address localhost:5701
{ Error: connect ECONNREFUSED 127.0.0.1:5701
at Object.exports._errnoException (util.js:1026:11)
at exports._exceptionWithHostPort (util.js:1049:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1085:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5701 }
Unhandled rejection Error: Unable to connect to any of the following addresses: localhost:5701
at Immediate.<anonymous> (C:\Users\Jennie Lyn\node_modules\hazelcast-client\lib\invocation\ClusterService.js:95:33)
at runCallback (timers.js:637:20)
at tryOnImmediate (timers.js:610:5)
at processImmediate [as _immediateCallback] (timers.js:582:5)
First i created an empty node project then:
npm install hazelcast-client --save
Then created one js file with:
var HazelcastClient = require('hazelcast-client').Client;
var person = {
firstName: "Joe",
lastName: "Doe",
age: 42
};
var map;
HazelcastClient.newHazelcastClient().then(function (hazelcastClient) {
map = hazelcastClient.getMap("personMap");
map.put(1, person).then(function (val) {
// prints previous value for key `1`
console.log(val);
});
map.get(1).then(function (value) {
console.log(value);
})
});
That's all the documentation says to do. Is there something else that needs to be done to start a single client cluster on the localhost using hazelcast-client for nodejs?
Before you start
download latest Hazelcast distribution from https://hazelcast.org/download/
unzip to any folder
start Hazelcast member using startup script /bin/start.sh
you can use samples now
Let me know if it works
Cheers,
Vik

Resources