feathersjs / feathers

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

Could not find a declaration file for module 'cors'. #3319

Closed billantoniadis closed 7 months ago

billantoniadis commented 8 months ago

Hello. I created a new application using npm create feathers@latest feathers-chat and I am able to successfully compile and run my application. As soon as I add authentication (as shown below), I am no longer able to compile. Did I miss a step? Am I doing something wrong, or is this a defect?

$ node --version
v18.18.0

$ npx feathers generate authentication
? Which authentication methods do you want to use? Other methods and providers can be added at any time. Auth0
? What is your authentication service name? user
? What path should the service be registered on? users
? What database is the service using? SQL
? Which schema definition format do you want to use? Schemas allow to type, validate, secure and populate data TypeBox  (recommended)
    Updated src/client.ts
    Wrote file src/services/users/users.schema.ts
    Wrote file src/services/users/users.ts
    Updated src/services/index.ts
    Wrote file src/services/users/users.shared.ts
    Wrote file test/services/users/users.test.ts
    Wrote file src/services/users/users.class.ts
    Wrote file migrations/20231020172649_user.ts
    Wrote file src/authentication.ts
    Updated src/app.ts
    Wrote file test/client.test.ts
    Updated src/declarations.ts
    Running npm install --save

added 73 packages, and audited 458 packages in 4s

71 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ npm run compile

> app@0.0.0 compile
> shx rm -rf lib/ && tsc

node_modules/@feathersjs/express/lib/index.d.ts:3:18 - error TS7016: Could not find a declaration file for module 'cors'. '/home/bill/Projects/Streamline/gva.web/app/node_modules/cors/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/cors` if it exists or add a new declaration (.d.ts) file containing `declare module 'cors';`

3 import cors from 'cors';
                   ~~~~~~

Found 1 error in node_modules/@feathersjs/express/lib/index.d.ts:3
daffl commented 8 months ago

I am not able to reproduce this. Is this consistently reproducible? What are the options you chose?

billantoniadis commented 8 months ago

Thank you for the reply, David. I am able to consistently reproduce using the options listed above (what I selected is shown after the question mark). Note that Auth0 is the only authentication method I selected. I am able to easily work around this by including "@types/cors": "^2.8.15" to the "devDepencies" in package.json. It's just strange that it is happening.

fidelio314 commented 8 months ago

hi @billantoniadis i had the same issue. and i have one more: https://github.com/feathersjs/feathers/issues/3322

anyway for the cors i added the type