Search code examples
reactjsreact-d3

use d3 v3 instead of d3 v4 react js


I am importing d3 library using:

import * as d3 from 'd3'; 

But it gives me this error:

15:20-27 "export 'time' (imported as 'd3') was not found in 'd3'

The reason being, the code is using d3 v3 and I am importing d3 v4. How do I restrict it to using d3 v3 instead ? In package.json, then d3 version looks like:

"d3": "^5.1.0"

Solution

  • Try the latest v3 version setting it directly in your package.json:

    "d3": "3.5.17"
    

    Then proceed to install again the packages with your favorite package manager:

    npm install
    

    or

    yarn install
    

    If using npm and having a version upper than 5, I would suggest you to delete first the package-lock.json to avoid any problem.