-
-
Notifications
You must be signed in to change notification settings - Fork 840
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
Uncaught ReferenceError: window is not defined #190
Comments
Hello, |
@wojtekmaj thanks for your answer,I close this issue |
Update: React-PDF 4.0 comes with support for Webpack 4.0. Here's a solution by @iki:
|
@wojtekmaj |
@wojtekmaj I'm using webpack 4 and the latest version of this package and am getting this issue. Has anyone found a good fix? I'm using create react-app. If I import the package directly it doesnt find anything, if I import from "react-pdf/dist/entry.webpack" I get it to say PDF Loading and Page 1 of ____ with that error in the console. This is with a create-react-app. |
same issue and need help🚑
|
change output: {
++ globalObject: 'this'
} example: output: {
globalObject: 'this',
// The build folder.
path: isEnvProduction ? paths.appBuild : undefined,
// Add /* filename */ comments to generated require()s in the output.
pathinfo: isEnvDevelopment,
// There will be one main bundle, and one file per asynchronous chunk.
// In development, it does not produce real files.
filename: isEnvProduction
? 'static/js/[name].[contenthash:8].js'
: isEnvDevelopment && 'static/js/bundle.js',
// TODO: remove this when upgrading to webpack 5
futureEmitAssets: true,
// There are also additional JS chunk files if you use code splitting.
chunkFilename: isEnvProduction
? 'static/js/[name].[contenthash:8].chunk.js'
: isEnvDevelopment && 'static/js/[name].chunk.js',
// We inferred the "public path" (such as / or /my-project) from homepage.
// We use "/" in development.
publicPath: publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: isEnvProduction
? info =>
path
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, '/')
: isEnvDevelopment &&
(info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
}, |
I am having the same issue. Is the above a long term solution? I don't have a react-scripts folder in my node_modules. Wondering where this folder came from? Environment: |
Yeah, suggested solution is globalObject: this. #190 (comment) |
Is there a solution for for Create-React-App project. I am facing similar issue Uncaught ReferenceError: window is not defined
at bootstrap:1
at bootstrap:788 |
That should work in Create-React-App, unless it's very outdated, since they did exactly what's suggested as a solution, almost a year ago: https://github.com/facebook/create-react-app/pull/7742/files |
thank you, this solution work for me |
Build failure happens on testcafe `https://app.circleci.com/pipelines/github/Open-Attestation/decentralized-renderer-react-template/30/workflows/327edc02-78e4-438a-bf67-b202b19b12c4/jobs/31` with the error `window is not defined` According to wojtekmaj/react-pdf#190 it could be solve by adding the option `globalObject: "this"` to webpack. This was also added into create-react-app.
in console
my package
how to solve this problem?????
The text was updated successfully, but these errors were encountered: