sapper icon indicating copy to clipboard operation
sapper copied to clipboard

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

Open btakita opened this issue 5 years ago • 8 comments

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

node_modules/.pnpm/[email protected][email protected]/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.

btakita avatar Oct 02 '20 23:10 btakita

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?

ehrencrona avatar Oct 09 '20 08:10 ehrencrona

Is this issue resolved?

TheComputerM avatar Oct 13 '20 07:10 TheComputerM

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

98mux avatar Oct 22 '20 16:10 98mux

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

smozely avatar Nov 04 '20 04:11 smozely

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 🤒

tcd93 avatar Feb 05 '21 07:02 tcd93

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.

RamiAwar avatar Mar 03 '21 11:03 RamiAwar

@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.

laurentS avatar Mar 07 '21 20:03 laurentS

@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.

RamiAwar avatar Mar 07 '21 20:03 RamiAwar