0

I'm building an app using electron with electron-react-boilerplate found here https://github.com/chentsulin/electron-react-boilerplate.git , it's all working fine.

But when I am trying to use D3, electron always throws me the error zTypeError: Cannot read property 'version' of undefined. (ie : console.log(d3.version) ).

My Config:

  • Electron 1.4.15
  • Chromium 53.0.2785.143
  • [email protected] | win32 | x64
  • react 15.4.2
  • d3 4.5.0

I hope someone can help with this issue.

1
  • If you're using the latest version of electron-react-boilerplate, shouldn't you be adding the <script>var d3 = require("d3")</script> to app.html? Commented Feb 18, 2017 at 13:19

1 Answer 1

1

I simply use var d3 = require('d3'); at the top of any jsx file that requires d3. This works for both of the electron + d3 based apps that I am currently working on.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, man, your answer is right and it's all working fine.
Glad it worked out. I should mention that certain libraries I require in this manner are not available in the chrome debugger namespace even though they are internally available for use within the context of each js/jsx file in which they are imported. For those libraries, I add in window.d3 = d3; so that they are available in the console debugger for easy testing/prototyping. I believe d3 doesn't require this as the way its exports are handled results in it being available by default in the global namespace, but this is handy for other libraries where this may not be the case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.