Node.JS include Jade file errno: -2, - node.js

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

Related

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

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'
}

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

spawnSync('npm', ['install']) gives [Error: spawnSync npm ENOENT]

I am having an issue with spawnSync is giving me ENOENT with simple "npm install". Can someone please help me?
======= NODE SCRIPT ==========
var child = require('child_process').spawnSync('npm', ['install']);
console.log(child.error);
===== OUTPUT ==========
[Error: spawnSync npm ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawnSync npm',
path: 'npm',
spawnargs: [ 'install' ]
only on windows but not on OS X.
This happens on
windows 7 x64
node version: 4.4.3
npm version: 2.15.1
I figured out the issue. On Windows, some commands need to be suffixed with .cmd in order to work. In this example, this updated command works for me:
require('child_process').spawnSync('npm.cmd', ['install']);
Or you can use cross-spawn to make it work cross-platform
I solved this by specifying the shell to be the v1 32-bit Powershell executable.
I don't know if there is a more reliable method of getting the Powershell executable path, but this is what I did:
const { spawnSync } = require('child_process')
const path = require('path')
const shell = process.platform === 'win32'
? 'C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe'
: undefined
const r0 = spawnSync('pnpm', ['run', 'build'], {
cwd: path.join(__dirname, '..', 'projects', 'project-name'),
env: process.env,
stdio: 'inherit',
shell
})
if (r0.error) {
console.log(r0.error)
process.exit(1)
}

Resources