Using laravel browsershot - node.js

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);
});

Related

child_process.spawnSync error 'ENOENT' when unzipping a file

I'm trying to execute a cli command using child_process.spawnSync to unzip a file, but when I run the code it says ENOENT even though the command works fine.
const result = spawnSync(`unzip ${path}`, [
passwordArg, // ''
outputArg, // ''
]);
// console.log(result)
error: Error: spawnSync unzip /<...>/unzipFiles/test/zipp.zip ENOENT
...
errno: -2,
code: 'ENOENT',
syscall: 'spawnSync unzip /<...>/unzipFiles/test/zipp.zip',
path: 'unzip /<...>/unzipFiles/test/zipp.zip',
spawnargs: ['', '']
If I copy and paste and execute the exact value for path, i.e. unzip /<...>/unzipFiles/test/zipp.zip, it runs as expected.
Any help would be much appreciated.

Is There a way to get the full path of file dependencies in Madge API?

I'm using Magde API (https://github.com/pahen/madge/blob/master/README.md) to generate the dependency graph of my JS file...
Once the dependencies are return as object, the file paths are not clearly documented... I was wondering if there exists a way to tell Madge to specify the full path not the cut it
I want to get the dependencies of this file:
import * as t from 'C:/Users/Tec/todolist_example_jest/req2.js';
function formatName(user) {
return user.firstName + ' ' + user.lastName;
}
const element = (
<h1>
Hello, {formatName(user)}!
</h1>
);
const user = {
firstName: 'Harper',
lastName: 'Perez'
};
As we can see there exists a dependency on this file:
'C:/Users/Tec/todolist_example_jest/req2.js'; But when using madge to get the dependencies ... look below to see what is the output
Here is the code snippet:
madge('file path').then((res) => {
dependencies = res.obj(); // the dependencies as an object
console.log(dependencies);
});
and this is the output:
{
'../../../../todolist_example_jest/req2.js': [],
'simpleElement.jsx': [ '../../../../todolist_example_jest/req2.js' ]
}
../../../../todolist_example_jest/req2.js
node:fs:585
handleErrorFromBinding(ctx);
^
Error: ENOENT: no such file or directory, open '../../../../todolist_example_jest/req2.js'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at C:\Users\Tec\React Native Applications\Upload-main\backend\app.js:47:27
at Array.forEach (<anonymous>)
at C:\Users\Tec\React Native Applications\Upload-main\backend\app.js:44:33 {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: '../../../../todolist_example_jest/req2.js'
}

code: 'ENOENT', message: 'No such file or directory' when using opencv.js in node-project

I'm using opencv.js for face detection. When I run this html file with the linked js files (opecv.js,utils.js) using a live server, it works.But,now when I copy the same files in my node project,and render this html page, I get the following error.
Uncaught
ErrnoError {node: undefined, errno: 2, code: 'ENOENT', message: 'No such file or directory', setErrno: ƒ, …}
code: "ENOENT"
errno: 2
message: "No such file or directory"
node: undefined
setErrno: ƒ (errno)
arguments: null
caller: null
length: 1
name: ""
prototype: {constructor: ƒ}
[[FunctionLocation]]: opencv.js:24
[[Prototype]]: ƒ ()
[[Scopes]]: Scopes[4]
stack: "<generic error, no stack>"
[[Prototype]]: Error at Object.ensureErrnoError (http://127.0.0.1:3000/js/opencv.js:24:8492014) at Object.staticInit (http://127.0.0.1:3000/js/opencv.js:24:8492254) at http:

fs.unlink EBUSY error

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...

Node.JS include Jade file errno: -2,

Error when i try to include file in jade
html
include head.jade
body
{
errno: -2,
code: "ENOENT",
syscall: "open",
path: "/server/layouts/head.jade"
}
path is correctly 100%, pls help me to fix this problem!
Use the ./ notation to ensure you are loading from the current path.
html
include ./head.jade
body

Resources