PHPLint: Error thrown using PHPLint but not with PHP - npm

I'm using the PHPLint NPM package with Gulp but am getting a PHP error when I run it. When I run the failed command with PHP, I do not receive the error.
The task runs successfully without any errors in the files I'm linting, so I can't think of issues with gulp.
php.ini has error reporting enabled:
error_reporting = E_ALL
display_errors = On
Command using PHPLint:
$ gulp phplint
[17:38:24] Using gulpfile C:\laragon\www\wp\wp-content\plugins\wp-plugin-jumpstart\gulpfile.js
[17:38:24] Starting 'phplint'...
[17:38:24] 'phplint' errored after 102 ms
[17:38:24] Error: Command failed: php -d display_errors=1 -l classes/Get_Started.php
at ChildProcess.exithandler (node:child_process:397:12)
at ChildProcess.emit (node:events:390:28)
at ChildProcess.emit (node:domain:537:15)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
at Process.callbackTrampoline (node:internal/async_hooks:130:17)
Running that failed command through PHP:
$ php -d display_errors=1 -l classes/Get_Started.php
Parse error: syntax error, unexpected 'class' (T_CLASS) in classes/Get_Started.php on line 5
Errors parsing classes/Get_Started.php
gulp.js
gulp.task('phplint', function (cb) {
phplint(['**/*.php', '!vendor/**', '!node_modules/**'], { limit: 10 }, function (err, stdout, stderr) {
if (err) {
cb(err);
process.exit(1);
}
cb();
console.log('PHP Linted Successfully');
});
});

Related

React-native-windows installation

I tried to install react-native-windows. I have some troubleshoot with the command:
npx react-native-windows-init --overwrite
NoLatestReactNativeWindows: Error: No version of react-native-windows#latest found
at getLatestRNWVersion (C:\Users\XXXX\AppData
Local\npm-cache_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\src\Cli.ts:249:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Object.reactNativeWindowsInit (C:\Users\XXXX\AppData\Local\npm-cache_npx\966c6a96be6f5a32\node_modules\react-native-windows-init\src\Cli.ts:533:36) {
type: 'NoLatestReactNativeWindows',
data: undefined
}
Command failed. Re-run the command with --verbose for more information.

How do I use Vite and Jest with IntelliJ?

I am trying to run a Jest integration test from Intellij. I right click and say run it tries to run but then I get...
/bin/sh: vite: command not found
I tried adding this to the env vars in the Intellij Run Dialog....
PATH=$PATH:/my/dir/node_modules/.bin
But then I get...
env: node: No such file or directory
node:events:371
throw er; // Unhandled 'error' event
^
Error: spawn pgrep ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn pgrep',
path: 'pgrep',
spawnargs: [ '-P', 6190 ]
}
I can confirm that vite is in /my/dir/node_modules/.bin and npx vite works from terminal. Vite is not (nor will I) installed globally
In my case I was using Puppeteer to run integration tests in the browser. Adding npm here...
module.exports = {
...
server: {
command: `npx vite --port 8080 --mode ${process.env.ENV_MODE || "development"}`,
port: 8080,
launchTimeout: 10000,
},
};
Notice was vite --port 8080 now npx vite --port 8080
This may not work with some older versions of NPM that don't include npx (don't remember version but think it is behind LTS).

unable to start server , npm start gives error

I tried to start development server using npm start
all installation procedures were according to mentioned on https://facebook.github.io/react-native/docs/getting-started
I am getting error as following :
Looking for JS files in /home/akash/appme
Loading dependency graph...internal/fs/watchers.js:173
throw error;
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/akash/appme/node_modules/jest-jasmine2/node_modules'
at FSWatcher.start (internal/fs/watchers.js:165:26)
at Object.watch (fs.js:1270:11)
at NodeWatcher.watchdir (/home/akash/appme/node_modules/sane/src/node_watcher.js:159:22)
at Walker.<anonymous> (/home/akash/appme/node_modules/sane/src/common.js:109:31)
at Walker.emit (events.js:200:13)
at /home/akash/appme/node_modules/walker/lib/walker.js:69:16
at go$readdir$cb (/home/akash/appme/node_modules/graceful-fs/graceful-fs.js:162:14)
at FSReqCallback.oncomplete (fs.js:153:23) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/home/akash/appme/node_modules/jest-jasmine2/node_modules',
filename: '/home/akash/appme/node_modules/jest-jasmine2/node_modules'
}
It’s hitting your system's file watchers limit
Try echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Source : https://github.com/gatsbyjs/gatsby/issues/11406#issuecomment-458769756
In VSCode try edit setting.json
File --> Preferences --> Settings --> OpenSettings
and exclude specific workspace directories, eg
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
}
source: https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc

Phantom manager could not start all workers

I trying to create a pdf using phamton-html-to-pdf and ejs for templating. The setup work greate in my local dev env, but not in production. The problem is that in my server prod the pdf is created but it is empty.
const ejs = require('ejs');
const fs = require('fs');
const conversion = require("phantom-html-to-pdf")({
phantomPath: require("phantomjs-prebuilt").path
});
function createPdf (data, template, directory) {
var options = {};
var html = ejs.renderFile(__dirname + `/template/${template}.ejs`, {data: data}, options, function(err, str){
if(err){
return err
}
return str
});
var filepath = null
conversion({ html: html, printDelay: 5000}, (err, pdf) => {
var output = fs.createWriteStream(`documents/${directory}/${data.Référence}.pdf`)
pdf.stream.pipe(output);
});
}
module.exports = createPdf;
{ Error: phantom manager could not start all workers..
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomManager.js:66:47
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomWorker.js:115:24
at /home/website/group-auto.com/node_modules/phantom-workers/lib/phantomWorker.js:140:20
at Socket.<anonymous> (/home/website/group-auto.com/node_modules/phantom-workers/lib/checkPortStatus.js:45:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:497:12)
[ { Error: Command failed: /home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/website/group-auto.com/node_modules/phantom-html-to-pdf/lib/scripts/serverScript.js
/home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs: 1: /home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs: Syntax error: word unexpected (expecting ")")
at ChildProcess.exithandler (child_process.js:198:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:920:16)
at Socket.<anonymous> (internal/child_process.js:351:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
killed: false,
code: 2,
signal: null,
cmd: '/home/website/group-auto.com/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any /home/website/group-auto.com/node_modules/phantom-html-to-pdf/lib/scripts/serverScript.js' },
I have no idea where to look for error, please help
You have to install 'libfontconfig' in your server.
macOS sierra update works only with phantomjs2.
linux may need to additionally install fontconfig package.
Centos - sudo yum install -y fontconfig
Debian/Ubuntu - sudo apt-get install -y libfontconfig
I had this problem with phantom-html-to-pdf (0.5.6).
In my case, my config was :
const pdf = require("phantom-html-to-pdf")({
// number of allocated phantomjs processes
numberOfWorkers: 3,
// timeout in ms for html conversion, when the timeout is reached, the phantom process is recycled
timeout: 10000,
// directory where are stored temporary html and pdf files
tmpDir: __dirname + "/tmp/",
phantomPath: "/usr/bin/phantomjs"
});
But my phantomPath was useless cause they're no executable at phantomPath in my case (we propably remove it for some reasons).
const pdf = require("phantom-html-to-pdf")({
// number of allocated phantomjs processes
numberOfWorkers: 3,
// timeout in ms for html conversion, when the timeout is reached, the phantom process is recycled
timeout: 10000,
// directory where are stored temporary html and pdf files
tmpDir: __dirname + "/tmp/"
});
My config without phantomPath works !

Error: no writecb in Transform class.?

Good day. Help me please.
There are some versions.
npm v3.10.6
node v4.5.
"gulp-file-include": "^0.14.0",
"gulp-remove-html": "^1.1.2"
There is part of gulpfile.js
fileinclude = require('gulp-file-include'),
gulpRemoveHtml = require('gulp-remove-html')
gulp.task('buildhtml', function() {
gulp.src(['app/*.html'])
.pipe(fileinclude({
prefix: '##'
}))
.pipe(gulpRemoveHtml())
.pipe(gulp.dest('dist/'));
});
There is result after running "gulp buildhtml". The problem appears today.
[11:31:46] Starting 'buildhtml'... [11:31:46] Finished 'buildhtml' after 8.83 ms events.js:141
throw er; // Unhandled 'error' event
^
Error: no writecb in Transform class
at afterTransform (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:74:40)
at TransformState.afterTransform (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:58:12)
at DestroyableTransform.fileInclude [as _transform] (C:\Projects\Projects\project1\node_modules\gulp-file-include\lib\index.js:49:9)
at DestroyableTransform.Transform._read (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:147:83)
at doWrite (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:313:64)
at writeOrBuffer (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (C:\Projects\Projects\project1\node_modules\gulp-file-include\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:241:11)
at write (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:623:24)
at flow (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:664:5)
at emitNone (events.js:67:13)
at DestroyableTransform.emit (events.js:166:7)
at emitReadable_ (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:448:10)
at emitReadable (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:444:5)
at readableAddChunk (C:\Projects\Projects\project1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:187:9)
If you use Gulp 4.0 alpha 3, Downgrade to Gulp 4.0 alpha 2 with
npm install -S gulpjs/gulp#6d71a65