sapper
sapper copied to clipboard
error TS2307: Cannot find module '@sapper/internal/manifest-server' or its corresponding type declarations.
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.
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?
Is this issue resolved?
I got a simular error. Got it from migrating from webpack v4 to v5
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
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
🤒
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 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 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.