feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.07k stars 752 forks source link

feathers generate service - custom service breaks #2948

Closed tvld closed 1 year ago

tvld commented 1 year ago
feathers generate service
Debugger attached.
? What kind of service is it? A custom service
? What is the name of the service? data
? Which path should the service be registered on? /data
? Does the service require authentication? No
Waiting for the debugger to disconnect...
/usr/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/read.js:12
    throw new Error(filepath + ' doesn\'t exist');
          ^

Error: /myAppPath/src/services/index.js doesn't exist
    at EditionInterface.module.exports [as read] (/usr/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/node_modules/mem-fs-editor/lib/actions/read.js:12:11)
    at ServiceGenerator.writing (/usr/lib/node_modules/@feathersjs/cli/node_modules/generator-feathers/generators/service/index.js:178:19)
    at Object.<anonymous> (/usr/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/lib/index.js:991:25)
    at /usr/lib/node_modules/@feathersjs/cli/node_modules/run-async/index.js:49:25
    at new Promise (<anonymous>)
    at /usr/lib/node_modules/@feathersjs/cli/node_modules/run-async/index.js:26:19
    at runLoop.add.once.once (/usr/lib/node_modules/@feathersjs/cli/node_modules/yeoman-generator/lib/index.js:992:11)
    at Immediate.<anonymous> (/usr/lib/node_modules/@feathersjs/cli/node_modules/grouped-queue/lib/subqueue.js:48:34)
    at processImmediate (node:internal/timers:466:21)
    at process.callbackTrampoline (node:internal/async_hooks:130:17)
tvld commented 1 year ago

I thought mixup of versions, so I tried:

sudo npm i -g @feathersjs/cli@pre
feathers generate service

But this generates faulty files. For example in class:

// This is a skeleton for a custom service class. Remove or add the methods you need here
export class TestService implements
    ServiceInterface<Test, TestData, TestParams, TestPatch> {  // >> >error, we do not need TestPatch ?
daffl commented 1 year ago

One thing to note for the pre-releases is that the CLI and dependency versions (@feathersjs/feathers etc.) should line up. The recommended way in new applications is to install the CLI as a development dependency into your project:

npm install @feathersjs/cli@pre --save-dev

And then use it via

npx feathers generate

That way everybody working on the project always has the correct generator available.

tvld commented 1 year ago

Yeb, that nails it )))