Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Feathers generate hook returns Cannot read property 'files' of undefined #206

Closed
florianbepunkt opened this issue Jan 12, 2020 · 4 comments

Comments

@florianbepunkt
Copy link

Steps to reproduce

Running feathers generate hook gives me the following stack trace

TypeError: Cannot read property 'files' of undefined
at subloop (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:92:58)
at /Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:107:13
at onDirRead (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:139:35)
at onStat (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:154:14)
at files (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:162:12)
at /Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:104:29
at onDirRead (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:139:35)
at onStat (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:154:14)
at files (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:162:12)
at /Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:104:29
at onDirRead (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:139:35)
at onStat (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:154:14)
at Object.files (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/node_modules/node-dir/lib/paths.js:162:12)
at HookGenerator._listServices (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/generators/hook/index.js:11:23)
at HookGenerator.prompting (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/generators/hook/index.js:94:27)
at Object. (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/lib/index.js:438:23)
Emitted 'error' event on HookGenerator instance at:
at Immediate. (/Users/florian/.nvm/versions/node/v13.1.0/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/lib/index.js:451:18)
at processImmediate (internal/timers.js:439:21)

Expected behavior

It should show the normal prompt to enter hook details (name, before/after, etc).

Actual behavior

See stack trace. It noteworthy, that I used the feathers generate hook command succesfully before in this project.

System configuration

Tell us about the applicable parts of your setup.

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

NodeJS version: 13.1.0 via nvm

Operating System: MacOS Catalina

@daffl
Copy link
Member

daffl commented Jan 12, 2020

This probably means that your directories.lib in package.json (https://github.com/feathersjs/feathers-chat/blob/master/package.json#L17) is not set or set to the wrong path. It must be set for the CLI to work.

@florianbepunkt
Copy link
Author

Thank you. I can replicate the error as soon as I have an empty folder inside a service folder. Closing this as it is no real issue once you know about it. But I guess there is a recursive directory/file loop where a check if missing if the directory is empty.

@rdewolff
Copy link

Could just replicate the same issue. Was sure that I had a clean repo after a checkout, but an empty dir in src\services was causing the same error for me. Thanks for sharing the solution @florianbepunkt.

@briancbarrow
Copy link

@florianbepunkt thank you for the solution. This was my issue as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants