Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@types/express] Namespace 'serveStatic' has no exported member 'RequestHandlerConstructor' #49595

Open
SunSeekerX opened this issue Nov 16, 2020 · 26 comments

Comments

@SunSeekerX
Copy link

No description provided.

@SunSeekerX
Copy link
Author

image

image

@sk-
Copy link

sk- commented Nov 16, 2020

It's a problem with the type dependencies for the express types. See #47339.

These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

@SunSeekerX
Copy link
Author

SunSeekerX commented Nov 16, 2020

It's a problem with the type dependencies for the express types. See #47339.

These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

Thank you,but i remove the @types/express dependence in my dependencies.
It works for me,my project base on nestjs, it seems does't need this dependence.

@adamgarcia4
Copy link

Also having this issue. +1

@ignlg
Copy link

ignlg commented Nov 18, 2020

Removing the @types/express dependency fixed the issue in a API project based on Express (without NestJS). Upgrading server-static typing dependencies did not work in my case.

@goalia
Copy link

goalia commented Nov 18, 2020

+1 when I installed twilio API with NestJS

@hrahimi270
Copy link

This helped me as a temp solution:
yarn add @types/express@4.17.8

@jonsadka
Copy link

Removing the @types/express dependency fixed the issue in a API project based on Express (without NestJS)

Same for me

@DmytroA
Copy link

DmytroA commented Nov 23, 2020

+1 when I installed twilio API with NestJS

@Benjamin-Gardien were you able to solve problem with Twilio api?

@goalia
Copy link

goalia commented Nov 23, 2020

@DmytroA it's my teammate @QuanticPotatoes who solved this issue 👌🏼

@yannickschuchmann
Copy link

I'm in a firebase project so for me the issue was with firebase-functions.
It uses fixed version of @types/express@4.17.3.

Since 4.17.9 is backwards compatible (fortunately 😄) I've set the resolution for all express types to 4.17.9. And that solved it for me. 🎉

// package.json
{
  "dependencies": {
    "@types/express": "4.17.9"
  // ...
  },
  "resolutions": {
    "@types/express": "4.17.9"
  }
}

@deividr
Copy link

deividr commented Dec 12, 2020

It's a problem with the type dependencies for the express types. See #47339.

These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

Its works for me... Thanks!!!

@maiconmichelon
Copy link

It's a problem with the type dependencies for the express types. See #47339.

These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

I use yarn, then I removed those dependencies from yarn.lock and installed again and It worked for me, thanks!

@exsesx
Copy link

exsesx commented Dec 17, 2020

It's a problem with the type dependencies for the express types. See #47339.
These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

I use yarn, then I removed those dependencies from yarn.lock and installed again and It worked for me, thanks!

This works for me now too, thanks.

@phattranky
Copy link
Contributor

It's a problem with the type dependencies for the express types. See #47339.
These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

Thank you,but i remove the @types/express dependence in my dependencies.
It works for me,my project base on nestjs, it seems does't need this dependence.

Works for me as well. I'm using NestJS

@andrerpena
Copy link

Literally removing "@types/express": "^4.17.11", from my package.json did the trick.

abernix added a commit to apollographql/apollo-server that referenced this issue Mar 7, 2021
...with a little extra help from @abernix because these types seem like
they're acting up again.  This time, I've found another issue on
DefinitelyTyped that seems like it's prescribing a solution that was
occurring in this particular attempt at updating the types, resulting in the
error message of:

  Namespace 'serveStatic' has no exported member 'RequestHandlerConstructor'

The (attempted, but seemingly working) fix was:

    npm update @types/express-serve-static-core --depth 2
    npm update @types/serve-static --depth 2

Ref: DefinitelyTyped/DefinitelyTyped#49595

But also, in reverse chronological order at attempted resolution:

Ref: 6e86f67
Ref: #4493
Ref: c67e8ec
Cc: @glasser
abernix added a commit to apollographql/apollo-server that referenced this issue Mar 7, 2021
...with a little extra help from @abernix because these types seem like
they're acting up again.  This time, I've found another issue on
DefinitelyTyped that seems like it's prescribing a solution that was
occurring in this particular attempt at updating the types, resulting in the
error message of:

  Namespace 'serveStatic' has no exported member 'RequestHandlerConstructor'

The (attempted, but seemingly working) fix was:

    npm update @types/express-serve-static-core --depth 2
    npm update @types/serve-static --depth 2

Ref: DefinitelyTyped/DefinitelyTyped#49595

But also, in reverse chronological order at attempted resolution:

Ref: 6e86f67
Ref: #4493
Ref: c67e8ec
Cc: @glasser

Co-authored-by: Jesse Rosenberger <git@jro.cc>
MarcusRiemer added a commit to MarcusRiemer/esqulino that referenced this issue Mar 30, 2021
@VincentDebug
Copy link

VincentDebug commented Apr 1, 2021

"@types/express": "4.17.11",
"@types/express-serve-static-core": "4.17.19",
"@types/serve-static": "1.13.9",

Add these to package.json, this helped me as a temp solution.

@cprodescu
Copy link

If you are having conflicts due to multiple libraries pulling in @types/express (in my case: probot, apollo-server-express), you can get away with using a resolution just for @types/serve-static:

"resolutions": {
  "@types/serve-static": "1.13.9"
}

anthonymonori added a commit to thirdwavelist/backend that referenced this issue May 9, 2021
- As per the suggestion in #70, applied version 2.24.0
- Added version of static types until DefinitelyTyped/DefinitelyTyped#49595 is fixed
- Updated express to 4.17.1
- Minor formatting in schema.ts
anthonymonori added a commit to thirdwavelist/backend that referenced this issue May 9, 2021
* Specify version of node required to run

* Update graphql and graphql-tools

- Update graphql to 15.5.0 as per #18 suggested
- Update graphql-tools to 7.0.4 as #30 suggested
- Ran npm ci to recreate package-lock to v2

* Update apollo-server-express

- As per the suggestion in #70, applied version 2.24.0
- Added version of static types until DefinitelyTyped/DefinitelyTyped#49595 is fixed
- Updated express to 4.17.1
- Minor formatting in schema.ts

* Fix outdated package-lock file
@fastfedora
Copy link

If you are having conflicts due to multiple libraries pulling in @types/express (in my case: probot, apollo-server-express), you can get away with using a resolution just for @types/serve-static:

"resolutions": {
  "@types/serve-static": "1.13.9"
}

This worked for me for firebase-functions when fixing the resolution for @types/express didn't work.

Jolg42 added a commit to prisma/ecosystem-tests that referenced this issue Jun 3, 2021
@Koslun
Copy link

Koslun commented Jun 30, 2021

Setting resolution to "@types/serve-static": "1.13.9" fixed it for me as well after trying a lot of other stuff.

A more permanent fix would be for @types/express to rely on "@types/serve-static": "> 1.13.9" instead of "@types/serve-static": "*" . That it relies on "*" is the reason fresh installs may work but plenty of random updates don't.

@viktorzavadil
Copy link

This helped me as a temp solution: yarn add @types/express@4.17.8

For me version 4.17.13 has same troubles.

@Yogu
Copy link
Contributor

Yogu commented Aug 23, 2022

The pull request created by @RMacfarlane triggered a test that basically said "these versions should not be specified"

Error: In package.json: Dependency @types/serve-static not in the allowed dependencies list.
Don't use a 'package.json' for @types dependencies unless this package relies on
an old version of types that have since been moved to the source repo.
For example, if package P used to have types on Definitely Typed at @types/P,
but now has its own types, a dependent package D will need to use package.json
to refer to @types/P if it relies on old versions of P's types.
In this case, please make a pull request to microsoft/DefinitelyTyped-tools adding @types/P to packages/definitions-> parser/allowedPackageJsonDependencies.txt.

The messages does not explain why this should not be done, and I can't find the source for this message.

There is an issue that explains the problem with specifying everything as "*" that also suggest to lift this restriction, but there has been no response since October 2019.

How can this be fixed then?

@sangimed
Copy link

It's a problem with the type dependencies for the express types. See #47339.

These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

it does solve the issue 😃

@connorads
Copy link

yarn user here - just deleted yarn.lock file and did yarn install again and it's working
connorads/lockbot#174

@DanielLMA
Copy link

yarn user here - just deleted yarn.lock file and did yarn install again and it's working connorads/lockbot#174

"express": "^4.17.1",
"@types/express": "^4.17.2",

deleted my package.lock.json and fresh npm i and no longer had this error

@ruscon
Copy link

ruscon commented Feb 4, 2024

It's a problem with the type dependencies for the express types. See #47339.

These commands fixed it for me:

npm update @types/express-serve-static-core --depth 2
npm update @types/serve-static --depth 2

works

I have

"express": "^4.18.2",
"express-correlation-id": "^2.0.1",

"@types/express": "^4.17.21",
"@types/express-correlation-id": "^1.2.4",
"@types/express-serve-static-core": "^4.17.43",
"@types/serve-static": "^1.15.5"

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

No branches or pull requests