TypeError: Cannot read property 'jest' of undefined at ServiceGenerator.writing

走远了吗. 提交于 2021-01-27 12:20:39

问题


I am trying to use cli tool for generating authentication in a featherjs app that wasn't built with featherCLI.

I have tried to added all the files it required but now it is giving me an error.

feathers generate authentication
? What authentication providers do you want to use? Other PassportJS strategies not in this list can still be configured manually. (Press <space> to select, <a> to toggle all, <i> t
o invert selection)Username + Password (Local)
? What is the name of the user (entity) service? users
? What kind of service is it? Sequelize
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'jest' of undefined
    at ServiceGenerator.writing (/usr/local/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/generators/service/index.js:142:45)
    at Object.<anonymous> (/usr/local/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/lib/index.js:424:27)
    at /usr/local/lib/node_modules/@feathersjs/cli/node_modules/run-async/index.js:25:25
    at new Promise (<anonymous>)
    at /usr/local/lib/node_modules/@feathersjs/cli/node_modules/run-async/index.js:24:19
    at self.env.runLoop.add.completed (/usr/local/lib/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 (/usr/local/lib/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)```

回答1:


I've just stumbled upon this error and it is caused when you have no devDependencies installed. This is a bug on feathersjs-cli.

\npm\node_modules\@feathersjs\cli\node_modules\generator-feathers\generators\service\index.js line 158 doesn't check for undefined:

const tester = this.pkg.devDependencies.jest ? 'jest' : 'mocha';

temporary workaround: install anything as a devDependency, for example jest

npm i --save-dev jest

then run generator again



来源:https://stackoverflow.com/questions/55352038/typeerror-cannot-read-property-jest-of-undefined-at-servicegenerator-writing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!