-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
"Blog" example doesn't work with latest release #108
Comments
Thank you for filing an issue! It seems you are on a Windows machine, is that correct? I tried that version of Node.js on a Mac and was able to get the example working correctly. My assumption is the path is being constructed wrong on Windows which leads to the wrong import path from what I can tell in the error. |
yes I use Windows. |
Thanks for confirming! I'll work on getting a VM set up when I get the chance and look into getting a fix out. From a quick look, I'm not sure exactly why the paths aren't being constructed properly (from the error at least) since I'm using |
thanks for info. I'll try to debug it too. |
Hi, I stumble on the same problem while trying mdxts. It seems here that the windows file API giving a path like this:
while I expect on linux/mac it should be resolve to this:
It seems that import is expecting the later. I simply put this in between and now I am a step further.
But now I get:
|
I recently solved a similar file path resolution problem for Windows. The solution is rather simple: import { join, posix, sep } from 'node:path';
import { pathToFileURL } from 'node:url';
import { globSync } from 'glob';
// Let's say you have a relative filepath, maybe from a glob library
// That filepath might have backslashes on Windows, and forward slashes on Unix
const root = process.cwd();
const path = './posts/*.mdx'
const files = await Promise.all(
globSync(
// Using node:path built-ins, we can normalize the filepath string to be Posix compliant
join(root, path).split(sep).join(posix.sep)
).map(
// Then, we'll use another built-in to convert a path like `C://path/to/file` to a `file://`
// protocol path that `import()` understands
(file) => import(pathToFileURL(file).toString())
)
) The important bits here are just replacing Windows path separators with Posix style separators, and then converting the resolved absolute path to use the This solution was informed by this Stack Overflow answer |
@souporserious went and used PS C:\Users\drake\GitHub\@saeris\mdxts-debug> bun dev
$ next
▲ Next.js 14.2.3
- Local: http://localhost:3000
✓ Starting...
automatically enabled Fast Refresh for 1 custom loader
✓ Ready in 8.7s
○ Compiling / ...
⨯ ./data.ts:15:103
Module not found: Can't resolve './postuild-a-button-component-in-react.mdx'
13 | baseDirectory: 'posts',
14 | sort: (a, b) => b.frontMatter.date.getTime() - a.frontMatter.date.getTime(),
> 15 | }, {'C:\Users\drake\GitHub\@saeris\mdxts-debug\posts\build-a-button-component-in-react.mdx': () => import('./posts\build-a-button-component-in-react.mdx')}, "{ title: string; date: Date; summary?: string; tags?: any; }")
| ^
16 |
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.tsx
⨯ ./data.ts:15:103
Module not found: Can't resolve './postuild-a-button-component-in-react.mdx'
13 | baseDirectory: 'posts',
14 | sort: (a, b) => b.frontMatter.date.getTime() - a.frontMatter.date.getTime(),
> 15 | }, {'C:\Users\drake\GitHub\@saeris\mdxts-debug\posts\build-a-button-component-in-react.mdx': () => import('./posts\build-a-button-component-in-react.mdx')}, "{ title: string; date: Date; summary?: string; tags?: any; }")
| ^
16 |
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.tsx
automatically enabled Fast Refresh for 1 custom loader
⨯ ./data.ts:15:103
Module not found: Can't resolve './postuild-a-button-component-in-react.mdx'
13 | baseDirectory: 'posts',
14 | sort: (a, b) => b.frontMatter.date.getTime() - a.frontMatter.date.getTime(),
> 15 | }, {'C:\Users\drake\GitHub\@saeris\mdxts-debug\posts\build-a-button-component-in-react.mdx': () => import('./posts\build-a-button-component-in-react.mdx')}, "{ title: string; date: Date; summary?: string; tags?: any; }")
| ^
16 |
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.tsx
GET / 500 in 11387ms Still appears to be an issue with the As an FYI, you can add an OS matrix in github actions to test on both Windows and Ubuntu. We did this to catch regressions over in Athena Crisis for this same category of issue. A good smoke test would probably be something close to what I did here, just create a new app using the blog starter and attempt to start the server and navigate to the home page. |
Ah, ok I'll have to dig deeper when I get a chance. I took another stab at it in a83ed0e to hopefully fix that issue and normalize to posix. Appreciate you taking a look! That's a great idea about setting up an action to test other operating systems. |
Nodejs v20.11.0
The text was updated successfully, but these errors were encountered: