gulp-notify icon indicating copy to clipboard operation
gulp-notify copied to clipboard

Error: SyntaxError in plugin 'gulp-notify'

Open dmhendricks opened this issue 5 years ago • 14 comments

Component Version Installed
gulp-notify v3.2.0
Operating System Mac OS X 10.14.3 Mojave
Gulp v4.0.0
Node.js v10.14.2
npm v6.8.0

I have gotten the error, "SyntaxError in plugin 'gulp-notify'" with various projects with which I use gulp-notify. I have Gulp logging errors to the console:

.on( 'error', console.error.bind( console ) )

I'd like to keep logging errors to the console, but I'd rather not get these errors. Full text of the error:

Message:
    Unexpected token { in JSON at position 129
[12:00:00] gulp-notify: [Error in notifier] SyntaxError in plugin "gulp-notify"

Thank you for the plugin! Daniel

dmhendricks avatar Feb 27 '19 20:02 dmhendricks

Have the same issue.

[Error in notifier] SyntaxError in plugin "gulp-notify"

petr0n avatar Mar 05 '19 20:03 petr0n

Same:

[15:56:02] gulp-notify: [Error in notifier] SyntaxError in plugin "gulp-notify" Message: Unexpected token { in JSON at position 133

jonsaul avatar Mar 10 '19 15:03 jonsaul

Same issue here as well:

[15:48:55] gulp-notify: [Error in notifier] SyntaxError in plugin "gulp-notify" Message: Unexpected token { in JSON at position 129

luniablue avatar Mar 28 '19 23:03 luniablue

Same here:

[21:03:20] gulp-notify: [Error in notifier] SyntaxError in plugin "gulp-notify" Message: Unexpected token { in JSON at position 129

orsem avatar Apr 08 '19 19:04 orsem

Same here. Any thoughts?

raymondSmith501 avatar Apr 16 '19 15:04 raymondSmith501

Same here, any thoughts when it might be fixed? Thanks.

max-sixblade avatar May 04 '19 15:05 max-sixblade

Use double quotes and pass your object as JSON(quotes around your properties):

notify({
  "title": "Gulp Task Complete",
  "message": "Message"
 })

mahammedzkhan avatar May 17 '19 10:05 mahammedzkhan

@mahammedzkhan Thanks for your hint, it helped.

yumitsu avatar Jul 09 '19 09:07 yumitsu

Hi!

I also ran into this error and tried to debug it a little bit. I was able to reproduce it using this script:

cp = require('child_process');

cmd = '/usr/local/lib/node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier';
options = [
    '-title', '"Hello from mgaw"',
    '-message', '"Trying to trigger invalid JSON"',
    '-hint', '"int:transient:1"',
    '-timeout', '"1"',
    '-json', '"true"'
];

x = () => {
    process = cp.execFile(cmd, options, (err, stdout, stderr) => {
        console.log('--- Response on stdout that should be valid JSON:\n' + stdout + '\n---\n');
    });
    console.log('Triggered notification, waiting for it to time out...');
}

range = n => [...Array(n).keys()];

range(10).forEach(x);

When I run it, often I will see this response, which I guess is the expected valid JSON:

{
  "activationType" : "timeout",
  "activationAt" : "2019-07-12 14:44:33 +0200",
  "deliveredAt" : "2019-07-12 14:44:32 +0200"
}

However sometimes two (or more) of those responses are concatenated together in a response such as:

{
  "activationType" : "timeout",
  "activationAt" : "2019-07-12 14:44:33 +0200",
  "deliveredAt" : "2019-07-12 14:44:31 +0200"
}{
  "activationType" : "timeout",
  "activationAt" : "2019-07-12 14:44:33 +0200",
  "deliveredAt" : "2019-07-12 14:44:31 +0200"
}

The SyntaxError happens when gulp-notify tries to parse this response.

This was using version 1.7.2 of terminal-notifier:

$ /usr/local/lib/node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier
terminal-notifier (1.7.2) is a command-line tool to send OS X User Notifications.

mgaw avatar Jul 12 '19 12:07 mgaw

@mgaw I was seeing the same behavior while trying to debug this on my machine as well. terminal-notifier v1.7.2 npm v6.10.1 node v12.4.0 macOS v10.14.5

tristanhall avatar Jul 16 '19 14:07 tristanhall

I had the same problem just now but the solution @mahammedzkhan mentioned works fine.

MCStreetguy avatar Jul 18 '19 14:07 MCStreetguy

@mahammedzkhan Dunno why - after your solution there were few notifications, and then gulp-notify broken completely. I guess this issue somehow related to vendored terminal-notifier, as OSX version works just OK.

yumitsu avatar Jul 22 '19 04:07 yumitsu

Hi,

Has there been any resolve on this at all? I am coming up against this issue.

Using Gulp Notify 4.0.0 Node : 20.6.1

Thanks in advance

kirstylmarks avatar Sep 27 '23 20:09 kirstylmarks

Use double quotes and pass your object as JSON(quotes around your properties):

notify({
  "title": "Gulp Task Complete",
  "message": "Message"
 })

Hi,

Have you tested this in even later versions of node? Definitely seems as if this plugin is not going to be supported anymore as later versions total fail with the notification system.

kirstylmarks avatar Sep 27 '23 21:09 kirstylmarks