MDsveX
MDsveX copied to clipboard
TypeError: Cannot read property 'parts' of undefined
MDsveX does not seem to run with Sapper. Have yet to test it with regular svelte. My custom project using it doesn't work, but works without it. I get the same error with the template: https://github.com/pngwn/sapper-mdsvex-template
Terminal output below:
C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template (master -> origin) ([email protected])
λ npm run dev
> [email protected] dev C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template
> sapper dev --ext '.svelte .svx'
• client
C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\src\node_modules\@sapper\internal\App.svelte
'level' is not defined
22: <Error {error} {status}/>
23: {:else}
24: <svelte:component this="{level-Infinity.component}" {...level-Infinity.props}/>
^
25: {/if}
26: </Layout>
C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\src\node_modules\@sapper\internal\App.svelte
'level' is not defined
22: <Error {error} {status}/>
23: {:else}
24: <svelte:component this="{level-Infinity.component}" {...level-Infinity.props}/>
^
25: {/if}
26: </Layout>
• server
C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\src\node_modules\@sapper\internal\App.svelte
'level' is not defined
22: <Error {error} {status}/>
23: {:else}
24: <svelte:component this="{level-Infinity.component}" {...level-Infinity.props}/>
^
25: {/if}
26: </Layout>
C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\src\node_modules\@sapper\internal\App.svelte
'level' is not defined
22: <Error {error} {status}/>
23: {:else}
24: <svelte:component this="{level-Infinity.component}" {...level-Infinity.props}/>
^
25: {/if}
26: </Layout>
✔ service worker (77ms)
> Listening on http://localhost:3000
(node:1856) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'parts' of undefined
at handle_page (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:2819:23)
at Array.find_route (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3103:4)
at nth_handler (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3224:14)
at C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3224:31
at Array.find_route (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:699:3)
at nth_handler (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3224:14)
at C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3224:31
at Array.<anonymous> (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3279:4)
at nth_handler (C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3224:14)
at C:\Users\EmNudge\Workspace\garbage\sapper-mdsvex-template\__sapper__\dev\server\server.js:3224:31
Could you tell me what operating system you are using?
It is better to use --ext \"svelte,svx\"
in the sapper template as it works in both windows and linux.
Could you tell me what operating system you are using?
Windows 10
It is better to use --ext "svelte,svx" in the sapper template as it works in both windows and linux.
This doesn't seem to affect anything
The line specifically I'm getting an error on is:
const route = page.parts[page.parts.length - 1].file;
handle_page
is passed page
. That function is called 3 times and it can only be undefined
twice. Both times in this function:
return function find_route(req, res, next) {
if (req.path === '/service-worker-index.html') {
const homePage = pages.find(page => page.pattern.test('/'));
handle_page(homePage, req, res);
return;
}
for (const page of pages) {
if (page.pattern.test(req.path)) {
handle_page(page, req, res);
return;
}
}
handle_error(req, res, 404, 'Not found');
};
It at least appears that all dependencies are installed locally, so I don't think I'd need to update some global package. I updated my global version of rollup just in case the local one wasn't being used, but no luck. The error went away once, but after running npm run dev
again, it came back. I have not been able to get rid of it since.
While the error was gone, I still got 'level' is not defined
errors and the page resulted in a 404.
Looking at the source for that, it seems to be correct. There is a local variable called level0
, but none named level
. Changing it removes that error.
The server files don't reload unless I rerun npm run dev
, but doing that rerwites those files, bringing the errors back each time.
Having the same problem, w10 user as well, @EmNudge do you still have the problem? Does it work with Svelte and without Sapper then?
The same problem occurs with https://github.com/shiryel/shiryel_blog
This repo appeared as a working example in https://github.com/pngwn/MDsveX/issues/122 and in my w10 computer is now broken (perhaps has never worked in w10, if the SO is the problem?)
@EmNudge @kuworking are you using any preprocessors?
@EmNudge @kuworking are you using any preprocessors?
Just following the basic example, mdsvex preprocessor only
https://github.com/pngwn/sapper-mdsvex-template/blob/master/rollup.config.js