我们当前使用的是npm
- 9.1.3和node
- v16.14.2。在Windows环境中,将npm
和node
更新到最新版本的好策略是什么?
是否涉及任何问题?
我的package.json
看起来像,
{
"name": "myreact",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "jest --verbose --colors",
"test:ci": "jest --ci --watchAll=false --colors --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageThreshold '{}'",
"test:coverage": "jest --verbose --coverage",
"test:watch": "jest --verbose --watch",
"test-debug": "node --inspect-brk --inspect ./node_modules/jest/bin/jest -i",
"start": "concurrently \"webpack-dev-server --mode development --open\" \"npm:stubby\"",
"start:iis": "webpack-dev-server --mode development --open --iis",
"build": "webpack --progress --mode production",
"build:dev": "webpack --progress --mode production --dev",
"build:prod": "lingui add-locale en && lingui extract --clean && lingui compile && webpack --mode production",
"lint": "eslint --cache --format codeframe --ext mjs,jsx,js src",
"add-locale": "lingui add-locale",
"extract": "lingui extract",
"compile": "lingui compile",
"stubby": "stubby --data stubs/stubby.yaml --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@craftjs/core": "0.2.0-beta.1",
"@craftjs/utils": "0.2.0-beta.1",
"@my/react-homegrown": "file:..//thirdparty/react/@my/my-react-homegrown-0.10.90.tgz",
"@lingui/core": "^2.9.1",
"@lingui/macro": "^2.9.1",
"@lingui/react": "^2.9.1",
"@material-ui/core": "^4.11.0",
"@material-ui/lab": "^4.0.0-alpha.56",
"@tinymce/tinymce-react": "^3.12.8",
"antlr4": "4.8.0",
"axios": "^0.26",
"classnames": "^2.3.1",
"date-fns": "^2.14.0",
"file-saver": "^2.0.5",
"formik": "^2.1.4",
"immer": "^9.0.12",
"json5": "^2.2.3",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"nanoid": "^3.1.32",
"prop-types": "^15.7.2",
"pubsub-js": "^1.9.2",
"qs": "^6.11.0",
"react": "^16.14.0",
"react-container-query": "^0.12.0",
"react-datepicker": "^2.16.0",
"react-dom": "^16.14.0",
"react-resize-detector": "^6.7.2",
"react-resize-panel": "^0.3.5",
"react-router-dom": "^5.2.0",
"react-to-print": "^2.14.7",
"react-virtualized-auto-sizer": "^1.0.5",
"react-window": "^1.8.6",
"recoil": "^0.7.0",
"resolve": "^1.22.1",
"sanitize-html": "2.7.1",
"sheetjs-style": "^0.15.8",
"tinymce": "^5.10.7",
"yup": "^0.32.11"
},
"peerDependencies": {
"react": "^16.14.0",
"react-dom": "^16.14.0"
},
"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/preset-react": "^7.14.5",
"@lingui/cli": "^2.9.2",
"@neutrinojs/airbnb": "^9.2.0",
"@neutrinojs/compile-loader": "^9.2.0",
"@neutrinojs/dev-server": "^9.4.0",
"@neutrinojs/eslint": "^9.2.0",
"@neutrinojs/jest": "^9.2.0",
"@neutrinojs/react": "^9.2.0",
"@tippyjs/react": "^4.0.5",
"@types/jest": "^25.2.3",
"assets-webpack-plugin": "^5.1.2",
"autoprefixer": "^9.8.4",
"babel-core": "^7.0.0-bridge.0",
"babel-plugin-macros": "^2.8.0",
"concurrently": "^5.3.0",
"core-js": "^2.6.11",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.5.0",
"eslint": "^6.8.0",
"eslint-plugin-react-hooks": "^4.0.6",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-junit": "12.1.0",
"moment-locales-webpack-plugin": "^1.2.0",
"neutrino": "^9.2.0",
"postcss-loader": "^3.0.0",
"rc-slider": "^8.7.1",
"react-overlays": "^1.2.0",
"react-scripts": "^4.0.3",
"sass": "^1.49.9",
"sass-loader": "^10.0.5",
"stubby": "^5.0.0",
"style-loader": "^1.2.1",
"styled-components": "^4.1.2",
"webpack": "^4.44.2",
"webpack-bundle-analyzer": "^4.3.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.1"
}
}
1条答案
按热度按时间atmip9wb1#
升级依赖项总是伴随着破坏旧依赖项的风险。通常,当您使用一个非常旧的模块,需要其他模块中的一个在旧版本上才能升级时,就会发生这种情况。
NPM
内置了一个很好的查找过期包的方法,试着在后端和前端项目中运行它:npm outdated
它将返回一个列表,其中可能包含大量过时的软件包。检查每个软件包,并尝试找到
Current
和Latest
版本之间差异最大的软件包。这些软件包将是最难升级的。此外,当前版本和最新版本之间差异非常小的软件包意味着它们可能已经过时。您可以使用我想检查他们的Github
存储库,看看最后一个commit
是什么时候的,以及它是否还在维护。升级到
Node 16
之前的版本可能会导致后端应用发生重大更改。对于前端和编译后的客户端,从React 16
升级到18
有很多突破性的变化。从Material-UI v4
迁移到v5
有很多突破性的变化。此外,从react-scripts 4
迁移到5
也有不少变化。一般来说,你会检查你所有的软件包,并根据业务需求做一些研究,这对企业来说是很常见的,因为这可能会导致一个必要的重构,所以在升级之前,你必须在保持旧模块一段时间之间做出选择。