Skip to content
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

a bunch of errors after import #238

Closed
junbinku opened this issue May 31, 2018 · 15 comments
Closed

a bunch of errors after import #238

junbinku opened this issue May 31, 2018 · 15 comments

Comments

@junbinku
Copy link

OS: Mac Sierra

React-pdf version: 0.7.6

Description:
Steps I did:

  • yarn add react-pdf/core
  • import { Page, Text, View, Document, StyleSheet } from 'react-pdf/core';

How to replicate issue including code snippet (if applies):

  • Uncaught Error: Module build failed: Error: ENOENT: no such file or directory
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/array/from.js
    Module build failed:
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/get-iterator.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/is-iterable.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/object/assign.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/object/create.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/object/define-property.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/object/set-prototype-of.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/symbol/index.js
  • ./node_modules/babel-runtime/node_modules/core-js/library/fn/symbol/iterator.js
  • ./node_modules/yoga-layout/dist/entry-browser.jsModule not found: Error: Can't resolve '../build/Release/nbind.js' in
  • client?b2a4:167 ./node_modules/react-reconciler/index.js
    Module not found: Error: Can't resolve './cjs/react-reconciler.development.js'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve './mixins/annotations'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve './mixins/color'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve './mixins/fonts'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve './mixins/images'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve './mixins/text'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve './mixins/vector'
  • ./node_modules/@react-pdf/core/node_modules/request/lib/har.js
    Module not found: Error: Can't resolve 'fs'
  • ./node_modules/pdfkit/js/document.js
    Module not found: Error: Can't resolve 'fs'
  • ./node_modules/png-js/png-node.js
    Module not found: Error: Can't resolve 'fs'
  • ./node_modules/@react-pdf/core/node_modules/tunnel-agent/index.js
    Module not found: Error: Can't resolve 'net'
  • ./node_modules/forever-agent/index.js
    Module not found: Error: Can't resolve 'net'
  • ./node_modules/tough-cookie/lib/cookie.js
    Module not found: Error: Can't resolve 'net'
  • ./node_modules/@react-pdf/core/node_modules/tunnel-agent/index.js
    Module not found: Error: Can't resolve 'tls'
  • ./node_modules/forever-agent/index.js
    Module not found: Error: Can't resolve 'tls'
@zeeshanjan82
Copy link

I am also getting lot of errors after I import:
import { Page, Text, View, Document, StyleSheet } from '@react-pdf/core';

image

@diegomura
Copy link
Owner

Are you using react-pdf in the web or on the server?

@zeeshanjan82
Copy link

@diegomura I am using in the web using react + redux not on the server

@diegomura
Copy link
Owner

To run on the browser you will need to do a special webpack setup. Please check this https://github.com/react-pdf/site/blob/master/webpack.config.js#L23 as reference

@junbinku
Copy link
Author

junbinku commented Jun 1, 2018

Im running on a local browser.
After I include the transform-loader stated on the docs it has lessen the errors.. but not completely.

Errors left:

  • cant resolve 'fs', 'net', 'tls'

@diegomura
Copy link
Owner

Did you included?

...
node: {
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
}

@junbinku
Copy link
Author

junbinku commented Jun 1, 2018

Oh sorry I didn't seen the end of the webpack but thanks!
It seem like there are no errors anymore but these warnings. Any ideas?

WARNING in ./node_modules/har-validator/node_modules/ajv/lib/async.js
119:15-28 Critical dependency: the request of a dependency is an expression
@ ./node_modules/har-validator/node_modules/ajv/lib/async.js
@ ./node_modules/har-validator/node_modules/ajv/lib/ajv.js
@ ./node_modules/har-validator/lib/node4/promise.js
@ ./node_modules/request/lib/har.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/@react-pdf/core/lib/utils/font.js
@ ./node_modules/@react-pdf/core/lib/font/index.js
@ ./node_modules/@react-pdf/core/lib/index.js
@ ./src/components/ExportPDF.js
@ ./src/components/ReportSummaryContainer.js
@ ./src/components/ReportsPage.js
@ ./src/components/Main.js
@ ./src/components/AegisApp.js
@ ./src/app.js
@ multi (webpack)-dev-server/client?http://localhost:8083 ./src/app.js

WARNING in ./node_modules/har-validator/node_modules/ajv/lib/compile/index.js
13:21-34 Critical dependency: the request of a dependency is an expression
@ ./node_modules/har-validator/node_modules/ajv/lib/compile/index.js
@ ./node_modules/har-validator/node_modules/ajv/lib/ajv.js
@ ./node_modules/har-validator/lib/node4/promise.js
@ ./node_modules/request/lib/har.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/@react-pdf/core/lib/utils/font.js
@ ./node_modules/@react-pdf/core/lib/font/index.js
@ ./node_modules/@react-pdf/core/lib/index.js
@ ./src/components/ExportPDF.js
@ ./src/components/ReportSummaryContainer.js
@ ./src/components/ReportsPage.js
@ ./src/components/Main.js
@ ./src/components/AegisApp.js
@ ./src/app.js
@ multi (webpack)-dev-server/client?http://localhost:8083 ./src/app.js

WARNING in ./node_modules/har-validator/node_modules/ajv/lib/async.js
96:20-33 Critical dependency: the request of a dependency is an expression
@ ./node_modules/har-validator/node_modules/ajv/lib/async.js
@ ./node_modules/har-validator/node_modules/ajv/lib/ajv.js
@ ./node_modules/har-validator/lib/node4/promise.js
@ ./node_modules/request/lib/har.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/@react-pdf/core/lib/utils/font.js
@ ./node_modules/@react-pdf/core/lib/font/index.js
@ ./node_modules/@react-pdf/core/lib/index.js
@ ./src/components/ExportPDF.js
@ ./src/components/ReportSummaryContainer.js
@ ./src/components/ReportsPage.js
@ ./src/components/Main.js
@ ./src/components/AegisApp.js
@ ./src/app.js
@ multi (webpack)-dev-server/client?http://localhost:8083 ./src/app.js

@diegomura
Copy link
Owner

No clue about that, but I'm not sure if it's something related to this project. Please try to emulate react-pdf site as much as you can

@junbinku
Copy link
Author

junbinku commented Jun 1, 2018

now im having this issue Uncaught ReferenceError: regeneratorRuntime is not defined

@diegomura
Copy link
Owner

In the README:

// to fix "regeneratorRuntime is not defined", which causes by "@react-pdf/*"
// also you can use "babel-polyfill"
import 'regenerator-runtime/runtime';

@junbinku
Copy link
Author

junbinku commented Jun 1, 2018

i did import 'regenerator-runtime/runtime'; on my react component itself where react-pdf is.

it is still not working.. do I need to include something in webpack?

@JuliaKuchina
Copy link

Same here. I get Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' after import 'regenerator-runtime/runtime'

@junbinku
Copy link
Author

junbinku commented Jun 4, 2018

I included a babel-polyfill in my webpack file and its alright now

module.exports={
entry: ['babel-polyfill','./src/app.js']

@diegomura
Copy link
Owner

Thanks for reporting the fix!

@ekilah
Copy link

ekilah commented Feb 26, 2019

@JSouthWind and anyone else that gets here from google, re: the CSP error - see #510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants