Feathers: CLI returning error when attempting to generate hook

Created on 22 Oct 2018  路  5Comments  路  Source: feathersjs/feathers

Steps to reproduce

A few days ago I started receiving an error whenever I try to generate a new hook for my app using feathers generate hook. Every other function of the cli seems to still work, including generating a new service. If I generate a new app and then try generating a hook in that one it works fine. I figured I messed something up with the hooks configuration in my project, but I'm able to generate a hook in the same project on Mac with no problems.

Expected behavior

After entering feathers generate hook, the cli should prompt for the hook's options (hook name, etc.)

Actual behavior

The cli returns the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'files' of undefined
    at subloop (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\node_modules\node-dir\lib\paths.js:92:58)
    at C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\node_modules\node-dir\lib\paths.js:107:13
    at onDirRead (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\node_modules\node-dir\lib\paths.js:139:35)
    at onStat (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\node_modules\node-dir\lib\paths.js:154:14)
    at Object.files (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\node_modules\node-dir\lib\paths.js:162:12)
    at HookGenerator._listServices (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\generators\hook\index.js:11:23)    at HookGenerator.prompting (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\generators\hook\index.js:64:27)
    at Object.<anonymous> (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\yeoman-generator\lib\index.js:424:27)
    at C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\run-async\index.js:25:25
    at new Promise (<anonymous>)
    at C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\run-async\index.js:24:19
    at self.env.runLoop.add.completed (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\yeoman-generator\lib\index.js:425:13)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
Emitted 'error' event at:
    at Immediate.setImmediate (C:\Users\[user folder]\AppData\Roaming\npm\node_modules\@feathersjs\cli\node_modules\yeoman-generator\lib\index.js:433:22)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

System configuration

Module versions (especially the part that's not working):

@feathersjs/cli: 3.6.8
@feathersjs/feathers: "3.2.3

NodeJS version: 10.12.0

Operating System: Windows 10 Pro v1809

Most helpful comment

I believe this issue might be caused by having empty folders in the /src/services directory. I ran into this issue again and looked through my project files to try to find what the issue might be, and I found some empty folders from services that I had since deleted. Once I deleted those folders, I was able to generate hooks again.

All 5 comments

Same here... very strange it started to show after I upgraded to the latest version of the cli..
wIll try to rollback to previous version and will update if it works...

I managed to fix the issue, but I'm still not quite sure what was causing it. I simply deleted and replaced my app's entire src/services directory with an exact copy of it from a different system. I'm guessing there was some hidden file in there that my source control wasn't picking up.

I believe this issue might be caused by having empty folders in the /src/services directory. I ran into this issue again and looked through my project files to try to find what the issue might be, and I found some empty folders from services that I had since deleted. Once I deleted those folders, I was able to generate hooks again.

Hi @EliSadaka sounds interesting. I will check it on my side as well ..

Thanks!

I believe this issue might be caused by having empty folders in the /src/services directory.

Yep, same case. same cause here. Thanks!

Was this page helpful?
0 / 5 - 0 ratings