-
-
Notifications
You must be signed in to change notification settings - Fork 901
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
./node_modules/.pnpm/canvas@2.11.2/node_modules/canvas/build/Release/canvas.node Module parse failed: Unexpected character '�' (1:2) #1508
Comments
Try not running react-pdf server side. It doesn't make a lot of sense to be honest, since canvas needs to be rendered in the browser anyway. Check out this solution here: #1504 (comment) |
I have set 'use client' directive and use dynamic import, not solved😫 // page.tsx
import dynamic, { DynamicOptions } from "next/dynamic";
const Component = dynamic(() => import("../components/PdfViewer"), {
ssr: false,
});
export default function Home() {
return <Component />;
} // component
"use client";
import { Document, Page, pdfjs } from "react-pdf";
import { useState } from "react";
...
return (
<>
<nav>
<button onClick={goToPrevPage}>Prev</button>
<button onClick={goToNextPage}>Next</button>
<p>
Page {pageNumber} of {numPages}
</p>
</nav>
{typeof window !== "undefined" && (
<Document
// file={resumeInfo.resumeUrl}
file="/sample.pdf"
onLoadSuccess={onDocumentLoadSuccess}
>
<Page pageNumber={pageNumber} />
</Document>
)}
</>
); |
I have the same issue. |
Ok, in next.config.js :
with npm install -D raw-loader |
this fix for me also, Next js 13.4 app router . |
im facing the same issue and the above method is not working for me |
If you're using this fix and happen to be using the stripe package, or any other packages with |
Worked for me. I'm using Next 14.0.3. Thanks! |
Before you start - checklist
Description
'use client' is already written in the code and import by next/dynamic(ssr: false)
I get the following error when dev:
Steps to reproduce
This is codesandbox
Expected behavior
I expect no errors
Actual behavior
Uncaught ModuleParseError: Module parse failed: Unexpected character '�' (1:2)
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: