alfy icon indicating copy to clipboard operation
alfy copied to clipboard

Cannot read property 'alfy' of undefined

Open IAIAE opened this issue 7 years ago • 3 comments

the index.js is


const alfy = require('alfy'); alfy.output([{ title: 'Unicorn' }, { title: 'Rainbow' }]);

and the console outputs the error:

[ERROR: input.scriptfilter] Code 1: {
  "items": [
    {
      "title": "Unicorn"
    },
    {
      "title": "Rainbow"
    }
  ]
}
{
  "items": [
    {
      "title": "TypeError: Cannot read property 'alfy' of undefined\n    at readPkgUp.then.result (/Users/pro/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.0408C61C-45B8-474D-B77D-B3C6691E4024/node_modules/alfy/lib/update-notification.js:7:26)",
      "subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
      "valid": false,
      "text": {
        "copy": "```\nTypeError: Cannot read property 'alfy' of undefined\n    at readPkgUp.then.result (/Users/pro/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.0408C61C-45B8-474D-B77D-B3C6691E4024/node_modules/alfy/lib/update-notification.js:7:26)\n```\n\n-\nregurl undefined\nAlfred 3.3.2\ndarwin x64 15.6.0",
        "largetype": "TypeError: Cannot read property 'alfy' of undefined\n    at readPkgUp.then.result (/Users/pro/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.0408C61C-45B8-474D-B77D-B3C6691E4024/node_modules/alfy/lib/update-notification.js:7:26)"
      },
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}
[2017-06-03 16:11:59][ERROR: input.scriptfilter] JSON error: Garbage at end. in JSON:
{
  "items": [
    {
      "title": "Unicorn"
    },
    {
      "title": "Rainbow"
    }
  ]
}
{
  "items": [
    {
      "title": "TypeError: Cannot read property 'alfy' of undefined\n    at readPkgUp.then.result (/Users/pro/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.0408C61C-45B8-474D-B77D-B3C6691E4024/node_modules/alfy/lib/update-notification.js:7:26)",
      "subtitle": "Press ⌘L to see the full error and ⌘C to copy it.",
      "valid": false,
      "text": {
        "copy": "```\nTypeError: Cannot read property 'alfy' of undefined\n    at readPkgUp.then.result (/Users/pro/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.0408C61C-45B8-474D-B77D-B3C6691E4024/node_modules/alfy/lib/update-notification.js:7:26)\n```\n\n-\nregurl undefined\nAlfred 3.3.2\ndarwin x64 15.6.0",
        "largetype": "TypeError: Cannot read property 'alfy' of undefined\n    at readPkgUp.then.result (/Users/pro/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.0408C61C-45B8-474D-B77D-B3C6691E4024/node_modules/alfy/lib/update-notification.js:7:26)"
      },
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

IAIAE avatar Jun 03 '17 08:06 IAIAE

Do you have a package.json file in your project directory? It looks like it can't find it.

SamVerschueren avatar Jun 03 '17 16:06 SamVerschueren

I just got that error when going through the steps for example workflow in the readme.rd file. Based on Sam's comment I ran 'npm init' and it works now.

GeorgeMSchaffer avatar Jun 06 '17 05:06 GeorgeMSchaffer

Exactly, you need a package.json file. I will have a look if I can make the error message more clear.

SamVerschueren avatar Jun 06 '17 06:06 SamVerschueren