Im trying to change from Grunt to Gulp now, and need a static server (gulp-connect doesn't provide a keepalive option, have no Idea why)
But I constantly get this error whenever trying to run the gulp browser-sync task:
[gulp] Using gulpfile C:\Users\Fernando\Projects\renovaintra.template\gulpfile.js
[gulp] Starting 'browser-sync'...
[gulp] Finished 'browser-sync' after 2.81 ms
[BS] Server running. Use this URL: http://192.168.1.102:3002
[BS] Serving files from: C:\Users\Fernando\Projects\renovaintra.template/public/
[BS] Watching files...
events.js:72
throw er; // Unhandled 'error' event
^
Error: This socket is closed.
at Socket._write (net.js:637:19)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Socket.Writable.write (_stream_writable.js:183:11)
at Socket.write (net.js:615:40)
at Socket.Writable.end (_stream_writable.js:341:10)
at Socket.end (net.js:396:31)
at Static.gzip (C:\Users\Fernando\Projects\renovaintra.template\node_modules\browser-sync\node_modules\socket.io\lib\static.js:207:14)
at ready (C:\Users\Fernando\Projects\renovaintra.template\node_modules\browser-sync\node_modules\socket.io\lib\static.js:370:14)
at C:\Users\Fernando\Projects\renovaintra.template\node_modules\browser-sync\node_modules\socket.io\lib\static.js:103:9
And here it is my gulp task:
__location = './public/';
gulp.task('browser-sync', function() {
browserSync.init([__location + '*.html'], {
server: {
baseDir: __location
}
});
});
Related
i want to run whatsapp-web.js module in replit using node.js
I tried the program in the library documentation. namely as follows
const qrcode = require('qrcode-terminal');
const { Client, LocalAuth } = require('whatsapp-web.js');
const client = new Client({
authStrategy: new LocalAuth()
});
client.on('qr', qr => {
qrcode.generate(qr, { small: true });
});
client.on('ready', () => {
console.log('Client is ready!');
});
client.on('message', async msg => {
const text = msg.body.toLowerCase() || '';
//check status
if (text === '!ping') {
msg.reply('pong');
}
});
client.initialize();
but when run. i get an error like this
/home/runner/coba-puppeteer/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
reject(new Error([
^
Error: Failed to launch the browser process!
/home/runner/coba-puppeteer/node_modules/whatsapp-web.js/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/home/runner/coba-puppeteer/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241:20)
at Interface.<anonymous> (/home/runner/coba-puppeteer/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:231:68)
at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:readline:590:8)
at Socket.onend (node:readline:280:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1358:12)
repl process died unexpectedly: exit status 1
I've found the problem I may be having is that it doesn't have the libraries required by puppeteer on the system. For example, the error message says "libgobject-2.0.so.0" could not be found. It may be a library that puppeteer needs to run. try installing the required libraries by running the following command in your terminal: sudo apt-get install libgobject-2.0-0
however replit cannot use sudo command
with error sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
has anyone ever managed to run a program using whatsapp-web.js in replit?
i am very confused what should i do
the expected output is that it will print the qrcode from whatsapp on the terminal
To start WebPack (which is in the parent folder) I use Gulp, but as soon as I try to go to the parent folder in the path, I get an error.
Gulp
var spawn = require('child_process').spawn;
gulp.task('_Scada2', function (done) {
spawn('webpack', [], { cwd: '../../Scada.Web/' })
.on('close', done);
});
get an error
[14:20:47] '_Scada2' errored after 4.47 ms
[14:20:47] Error: spawn webpack ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
at onErrorNT (internal/child_process.js:406:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Процесс завершен с кодом 1.
Try __dirname + '../../Scada.Web/'
I am learning Node.js via the book Node.js the Right Way. I am trying to run the following example to watch changes to a file called target.txt that resides in the the same directory as the .js file.
"use strict";
const
fs = require('fs'),
spawn = require('child_process').spawn,
filename = process.argv[2];
if (!filename) {
throw Error("A file to watch must be specified!");
}
fs.watch(filename, function () {
let ls = spawn('ls', ['-lh', filename]);
ls.stdout.pipe(process.stdout);
});
console.log("Now watching " + filename + " for changes...");
I get the following error when I change the text file and save it:
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn ls ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
Node.js version: v6.11.0
IDE: Visual Studio Code 1.13.1
OS: Windows 10 64x
There's no ls on Windows, you should use dir instead.
However, that's not an executable. To run .bat and .cmd files you can:
Spawn cmd.exe and pass those files as arguments:
require('child_process').spawn('cmd', ['/c', 'dir']);
Use spawn with the shell option set to true:
require('child_process').spawn('dir', [], { shell: true });
Use exec instead of spawn:
require('child_process').exec('dir', (err, stdout, stderr) => { ... });
For more on that, take a look at this section in the official docs.
EDIT:
I'm not sure I understood you question in the comment correctly, but if you go for the second option, for example, you code will look like this:
...
fs.watch(filename, function () {
let dir = spawn('dir', [filename], { shell: true });
dir.stdout.pipe(process.stdout);
});
...
Please, keep in mind you may need to adjust this code slightly. I'm writing all this from memory as I don't have access to a Windows machine right now, so I can't test it myself.
I'm trying to run a simple grunt task with protractor but everytime I receive an error on the console. I am using grunt with forever utility and placed various breakpoints take narrow down the error causing code. The selenium server created a session for the test cases but the system generates the following error while trying to execute the test suite.
Error: spawn node ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
at child_process.js:1137:20
at process._tickCallback (node.js:355:11)
[launcher] Process exited with error code 1
I cleared all the node processes and still the problem persisted. Any ideas?
Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
protractor: {
all: {
options: {
configFile: "conf.js",
keepAlive: true
}
}
}
});
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.registerTask('test', protractor);
};
my_spec.js
this.foreverMonitor = function(port){
forever.list(false, function(){
var child = new (forever.Monitor)('app.js', {
killTree: true,
silent: true
...
});
child.start();
forever.startServer(child);
});
}
var port = 5000;
foreverMonitor(port);
browser.getSession().then(function(sess){
console.log(sess.id);
});
describe('..', function(){
it('..', expect());
});
I'm trying to minify images with imagemin, but it falls with an error.
Can't understand what I've done wrong.
Here is my gulpfile
'use strict';
var gulp = require('gulp');
var imagemin = require('imagemin');
var clean = require('gulp-clean');
gulp.task('img', function () {
return gulp.src('src/img/**')
.pipe(imagemin())
.pipe(gulp.dest('build/img'));
});
gulp.task('clean', function() {
console.log('-----------удаляю build');
return gulp.src('build', {read: false})
.pipe(clean());
});
And an error message from console
$ gulp img
(node:14312) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[22:10:20] Using gulpfile Z:\a\gulpfile.js
[22:10:20] Starting 'img'...
[22:10:20] 'img' errored after 26 ms
[22:10:20] TypeError: dest.on is not a function
at DestroyableTransform.Readable.pipe (Z:\a\node_modules\vinyl-fs\node_modules\readable-stream\lib\_stream_readable.js:516:8)
at Gulp.<anonymous> (Z:\a\gulpfile.js:9:6)
at module.exports (Z:\a\node_modules\orchestrator\lib\runTask.js:34:7)
at Gulp.Orchestrator._runTask (Z:\a\node_modules\orchestrator\index.js:273:3)
at Gulp.Orchestrator._runStep (Z:\a\node_modules\orchestrator\index.js:214:10)
at Gulp.Orchestrator.start (Z:\a\node_modules\orchestrator\index.js:134:8)
at C:\Users\Artur\AppData\Roaming\npm\node_modules\gulp\node_modules\gulp-cli\lib\versioned\^3.7.0\index.js:46:20
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Function.Module.runMain (module.js:577:11)
Usually this error is thrown when you're trying to pipe() something that's not a stream to gulp.dest().
I see in your code var imagemin = require('imagemin'); - are you sure you didn't mean to write var imagemin = require('gulp-imagemin');? imagemin won't return a proper gulp stream, but gulp-imagemin will.