I've been working on a project that used d3 v5.5.0, moved it to another computer, and when I did npm install it now acts as if it's a higher version of d3?
Part of my program relies on the old way of d3 calling transform for zoom, and worked when it was that version. Yet even though in my packages it says it's got 5.5.0, it's throwing errors that event.transform was deprecated (Which happened in v6). How would it know it's deprecated if it should still be using 5.5.0? Also, if I do npm list
it says the version of d3@^5.16.0? Which even then that doesn't make sense as you can see from my package.json.
Here is my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"api": "npx json-server --watch .\\src\\components\\limit.json --port 8000"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"csvtojson": "^2.0.10",
"d3": "^5.5.0",
"react": "^16.4.2",
"react-dom": "^16.4.1",
"react-file-reader": "^1.1.4",
"react-request": "^3.2.0",
"react-router-dom": "^6.0.2",
"react-scripts": "^4.0.2",
"react-scroll-wheel-handler": "^2.0.1",
"styled-components": "^5.2.1",
"use-neo4j": "^0.3.5",
"webpack": "^4.44.2",
"write-json-file": "^4.3.0",
"xlsx": "^0.16.9"
}
}
CodePudding user response:
In your package.json
, you have specified d3 to be "^5.5.0"
. The ^
there says that the version to install must be at least version 5.5.0, so npm just installs the latest. If you want to force v5.5.0, you should specify it withput the ^
.
so your package.json should have "d3": "5.5.0"
instead of "d3": "^5.5.0"