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

error TS2307: Cannot find module '@sapper/internal/manifest-server' or its corresponding type declarations. #1583

Open
btakita opened this issue Oct 2, 2020 · 8 comments

Comments

@btakita
Copy link
Contributor

btakita commented Oct 2, 2020

On v0.28.10 with "strict": true in tsconfig.json & sapper/common in types, results with the error:

node_modules/.pnpm/sapper@0.28.10_svelte@3.29.0/node_modules/sapper/runtime/index.d.ts:20:36 - error TS2307: Cannot find module '@sapper/internal/manifest-server' or its corresponding type declarations.

20  import { Handler, Req, Res } from '@sapper/internal/manifest-server';
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error. Watching for file changes.
@ehrencrona
Copy link
Contributor

You shouldn't need to set types (nor typeRoots) in your tsconfig.json. You can see the standard tsconfig.json in the source of the setupTypeScript script.

What can be confusing is that src/node_modules/@sapper is created when building, so you need to run npm run build for @sapper/... imports to start working either in tsc or in your IDE.

That still doesn't quite explain your error message. Is there an import to sapper rather than @sapper/... somewhere in your code?

@TheComputerM
Copy link
Contributor

Is this issue resolved?

@98mux
Copy link

98mux commented Oct 22, 2020

I got a simular error. Got it from migrating from webpack v4 to v5

@smozely
Copy link

smozely commented Nov 4, 2020

I'm getting this error as well ... I've run the build already.

To me it looks like @sapper/internal/manifest-server doesn't actually export { Handler, Req, Res } in my repo ... so that explains the error there 🤔 ... thats about the limit of what I can see so far.

Actually get the same error if I take the template app, add typescript, and add strict to the TS config

@tcd93
Copy link

tcd93 commented Feb 5, 2021

I managed to get past this error by adding fullySpecified: false before 'svelte-loader'

rules: [
      {
        test: /\.m?js/,
        resolve: {
          fullySpecified: false
        }
      },
      {
        test: /\.(svelte|html)$/,
        exclude: {
          and: [/node_modules/],
          not: [/@sapper/],
        },
        use: {
          loader: 'svelte-loader'
        }
      }
...
]

The problem was the generated import statements in app.mjs & server.mjs did not specified file extensions (the error is not from Sapper but from rollup-plugin-typescript2 not supporting Webpack 5)

But now I'm hitting a new error: _internal_App_svelte__WEBPACK_IMPORTED_MODULE_9__.default.render is not a function
🤒

@RamiAwar
Copy link

RamiAwar commented Mar 3, 2021

The docs specifically mention:

import { SapperRequest, SapperResponse } from '@sapper/server';

function get(req: SapperRequest, res: SapperResponse, next: () => void) { ... }

But this doesn't work for me as I get:

@rollup/plugin-typescript TS2709: Cannot use namespace 'SapperRequest' as a type.

Looking at index.d.ts in @sapper, I don't see the exports for SapperRequest and SapperResponse. I think I'm facing an issue pretty close to this one.

@laurentS
Copy link

laurentS commented Mar 7, 2021

@RamiAwar I was having the same issue. Upgrading to sapper 0.29.1 and using import type { SapperRequest.... seems to have solved it for me.

@RamiAwar
Copy link

RamiAwar commented Mar 7, 2021

@laurentS I got it to work at some point, but it didn't result in autocomplete functionality. I ended up using Polka's Request and http ServerResponse.

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

No branches or pull requests

9 participants