Vue2最低⽀持Node版本调查
背景
确定Vue2最低⽀持的Node版本,可以在CI环境中,确定Node的⼀些信息,是否适合后端环境共享同⼀个Node版本呢。
Vue2项⽬
调研了Vue 2.6.11版本的package.json
其中Vue2使⽤Node是在编译事态使⽤,即是 webpack 使⽤。
从这个⽂件中,我们发现 Vue2使⽤ webpack4.28.4
"webpack": "~4.28.4",
{
"name": "vue",
"version": "2.6.11",
"description": "Reactive, component-oriented view layer for modern web interfaces.",
"main": "dist/vue.runtimemon.js",
"module": "dist/vue.runtime.esm.js",
"unpkg": "dist/vue.js",
"jsdelivr": "dist/vue.js",
"typings": "types/index.d.ts",
"files": [
"src",
"dist/*.js",
"types/*.d.ts"
],
"sideEffects": false,
"scripts": {
"dev": "rollup -w -c scripts/config.js --environment TARGET:web-full-dev",
"dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-cjs-dev",
"dev:esm": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-esm",
"dev:test": "karma start test/unit/fig.js",
"dev:ssr": "rollup -w -c scripts/config.js --environment TARGET:web-server-renderer",
"dev:compiler": "rollup -w -c scripts/config.js --environment TARGET:web-compiler ",
"dev:weex": "rollup -w -c scripts/config.js --environment TARGET:weex-framework",
"dev:weex:factory": "rollup -w -c scripts/config.js --environment TARGET:weex-factory",
"dev:weex:compiler": "rollup -w -c scripts/config.js --environment TARGET:weex-compiler ",
"build": "node scripts/build.js",
"build:ssr": "npm run build -- web-runtime-cjs,web-server-renderer",
"build:weex": "npm run build -- weex",
"test": "npm run lint && flow check && npm run test:types && npm run test:cover && npm run test:e2e -- --env phantomjs && npm run test:ssr && npm run test:weex",    "test:unit": "karma start test/unit/fig.js",
"test:cover": "karma start test/fig.js",
"test:e2e": "npm run build -- web-full-prod,web-server-basic-renderer && node test/e2e/runner.js",
"test:weex": "npm run build:weex && jasmine JASMINE_CONFIG_PATH=test/weex/jasmine.js",
"test:ssr": "npm run build:ssr && jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.js",
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2",
"test:types": "tsc -p ./types/test/tsconfig.json",
"lint": "eslint src scripts test",
"flow": "flow check",
"sauce": "karma start test/unit/fig.js",
"bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
"release": "bash scripts/release.sh",
"release:weex": "bash scripts/release-weex.sh",
"release:note": "node scripts/gen-release-note.js",
"commit": "git-cz"
},
"gitHooks": {
"pre-commit": "lint-staged",
"commit-msg": "node scripts/verify-commit-msg.js"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"repository": {
"type": "git",
"url": "git+github/vuejs/vue.git"
},
"keywords": [
"vue"
],
"author": "Evan You",
"license": "MIT",
"bugs": {
"url": "github/vuejs/vue/issues"
},
"homepage": "github/vuejs/vue#readme",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"@types/node": "^12.12.0",
"@types/webpack": "^4.4.22",
"acorn": "^5.2.1",
"babel-eslint": "^10.0.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^8.0.4",
"babel-plugin-istanbul": "^5.1.0",
"babel-plugin-transform-vue-jsx": "^4.0.1",
"babel-preset-flow-vue": "^1.0.0",
"buble": "^0.19.3",
"chalk": "^2.3.0",
"chromedriver": "^2.45.0",
"codecov": "^3.0.0",
"commitizen": "^2.9.6",
"conventional-changelog": "^1.1.3",
"cross-spawn": "^6.0.5",
"cz-conventional-changelog": "^2.0.0",
"de-indent": "^1.0.2",
"es6-promise": "^4.1.0",
"escodegen": "^1.8.1",
"eslint": "^5.7.0",
"eslint-plugin-flowtype": "^2.34.0",
"eslint-plugin-jasmine": "^2.8.4",
"file-loader": "^3.0.1",
"flow-bin": "^0.61.0",
"hash-sum": "^1.0.2",
"he": "^1.1.1",
"http-server": "^0.11.1",
"jasmine": "^2.99.0",
"jasmine-core": "^2.99.0",
"karma": "^3.1.1",
"karma-chrome-launcher": "^2.1.1",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.4",
"karma-safari-launcher": "^1.0.0",
"karma-sauce-launcher": "^2.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.0-rc.2",
"lint-staged": "^8.0.0",
"lodash": "^4.17.4",
"plate": "^4.4.0",
"lodash.uniq": "^4.5.0",
"lru-cache": "^5.1.1",
"nightwatch": "^0.9.16",
"nightwatch-helpers": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"puppeteer": "^1.11.0",
"resolve": "^1.3.3",
"rollup": "^1.0.0",
"rollup-plugin-alias": "^1.3.1",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-flow-no-whitespace": "^1.0.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.0.0",
"selenium-server": "^2.53.1",
"serialize-javascript": "^2.1.2",
"shelljs": "^0.8.1",
"terser": "^3.10.2",
"typescript": "^3.6.4",
"webpack": "~4.28.4",
"weex-js-runtime": "^0.23.6",
"weex-styler": "^0.3.0",
"yorkie": "^2.0.0"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Webpack
从其发布的列表中,到对应的4.28.4版本
下载后查看其中的package.json⽂件
从中查到,其基于node版本是6.11.5
"engines": {
"node": ">=6.11.5"
},
{
"name": "webpack",
"version": "4.28.4",
"author": "Tobias Koppers @sokra",
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff."  "license": "MIT",
"dependencies": {
"@webassemblyjs/ast": "1.7.11",
"@webassemblyjs/helper-module-context": "1.7.11",
"@webassemblyjs/wasm-edit": "1.7.11",
"@webassemblyjs/wasm-parser": "1.7.11",
"acorn": "^5.6.2",
"acorn-dynamic-import": "^3.0.0",
"ajv": "^6.1.0",
"ajv-keywords": "^3.1.0",
"chrome-trace-event": "^1.0.0",
"enhanced-resolve": "^4.1.0",
"eslint-scope": "^4.0.0",
"json-parse-better-errors": "^1.0.2",
"loader-runner": "^2.3.0",
"loader-utils": "^1.1.0",
"memory-fs": "~0.4.1",
"micromatch": "^3.1.8",
"mkdirp": "~0.5.0",
"neo-async": "^2.5.0",
"node-libs-browser": "^2.0.0",
"schema-utils": "^0.4.4",
"tapable": "^1.1.0",
"terser-webpack-plugin": "^1.1.0",
"watchpack": "^1.5.0",
"webpack-sources": "^1.3.0"
},
"devDependencies": {
"@types/node": "^9.6.4",
"@types/tapable": "^1.0.1",
"@types/webpack-sources": "^0.1.4",
"benchmark": "^2.1.1",
"bundle-loader": "~0.5.0",
"codacy-coverage": "^2.0.1",
"coffee-loader": "^0.9.0",
"coffeescript": "^1.10.0",
"coveralls": "^3.0.2",
"css-loader": "^0.28.3",
"es6-promise-polyfill": "^1.1.1",
"eslint": "^5.8.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-jest": "^21.26.2",
vue中reactive"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"express": "~4.13.1",
"file-loader": "^1.1.6",
"glob": "^7.1.3",
"husky": "^1.1.3",
"i18n-webpack-plugin": "^1.0.0",
"istanbul": "^0.4.5",
"jade": "^1.11.0",
"jade-loader": "~0.8.0",
"jest": "24.0.0-alpha.1",
"jest-junit": "^5.2.0",
"json-loader": "^0.5.7",
"json-schema-to-typescript": "^6.0.1",
"less": "^2.5.1",
"less-loader": "^4.0.3",
"lint-staged": "^8.0.4",
"lodash": "^4.17.4",
"prettier": "^1.14.3",
"pug": "^2.0.3",
"pug-loader": "^2.4.0",
"raw-loader": "~0.5.0",
"react": "^15.2.1",
"react-dom": "^15.2.1",
"rimraf": "^2.6.2",
"script-loader": "~0.7.0",
"simple-git": "^1.65.0",
"style-loader": "^0.19.1",
"typescript": "^3.0.0-rc",
"url-loader": "^0.6.2",
"val-loader": "^1.0.2",
"vm-browserify": "~0.0.0",
"wast-loader": "^1.5.5",
"webpack-dev-middleware": "^1.9.0",
"worker-loader": "^1.1.1",
"xxhashjs": "^0.2.1"
},
"engines": {
"node": ">=6.11.5"
},
"repository": {
"type": "git",
"url": "github/webpack/webpack.git"
},
"homepage": "github/webpack/webpack",
"main": "lib/webpack.js",
"web": "lib/webpack.web.js",
"bin": "./bin/webpack.js",
"files": [
"lib/",
"bin/",
"buildin/",
"declarations/",
"hot/",
"web_modules/",
"schemas/",
"SECURITY.md"
],
"scripts": {
"setup": "node ./setup/setup.js",
"test": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest",
"test:update-snapshots": "yarn jest -u",
"test:integration": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\"",
"test:basic": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/{TestCasesNormal,StatsTestCases,ConfigTestCases}.test.js\"",
"test:unit": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
"travis:integration": "yarn cover:init && yarn cover:integration --ci $JEST",
"travis:basic": "yarn test:basic --ci $JEST",
"travis:lint-unit": "yarn lint && yarn cover:init && yarn cover:unit --ci $JEST",
"travis:benchmark": "yarn benchmark --ci",
"appveyor:integration": "yarn cover:init && yarn cover:integration --ci %JEST%",
"appveyor:unit": "yarn cover:init && yarn cover:unit --ci %JEST%",
"appveyor:benchmark": "yarn benchmark --ci",
"build:examples": "cd examples && node buildAll.js",
"pretest": "yarn lint",
"prelint": "yarn setup",
"lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint",
"code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/fig.js\" \"examples/**/fig.js\"",
"type-lint": "tsc --pretty",
"special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
"special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
"fix": "yarn code-lint --fix && yarn special-lint-fix",
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/fig.js\" \"examples/**/we    "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
"cover": "yarn cover:init && yarn cover:all && yarn cover:report",
"cover:init": "rimraf coverage",
"cover:all": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --coverage",
"cover:integration": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.test.js\" --coverage",
"cover:unit": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\" --coverage",
"cover:report": "istanbul report"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js|{lib,setup,bin,hot,buildin,tooling,schemas}/**/*.js|test/*.js|{test,examples}/**/fig.js}": [
"eslint --cache"
]
},
"jest": {
"forceExit": true,
"setupFilesAfterEnv": [
"<rootDir>/test/setupTestFramework.js"
],
"testMatch": [
"<rootDir>/test/*.test.js",
"<rootDir>/test/*.unittest.js"
],
"watchPathIgnorePatterns": [
"<rootDir>/.git",
"<rootDir>/node_modules",
"<rootDir>/test/js",
"<rootDir>/test/browsertest/js",
"<rootDir>/test/fixtures/temp-cache-fixture",
"<rootDir>/test/fixtures/temp-",
"<rootDir>/benchmark",
"<rootDir>/examples/*/dist",
"<rootDir>/coverage",
"<rootDir>/.eslintcache"
],
"modulePathIgnorePatterns": [
"<rootDir>/.git",
"<rootDir>/node_modules/webpack/node_modules",
"<rootDir>/test/js",
"<rootDir>/test/browsertest/js",
"<rootDir>/test/fixtures/temp-cache-fixture",
"<rootDir>/test/fixtures/temp-",
"<rootDir>/benchmark",
"<rootDir>/examples/*/dist",
"<rootDir>/coverage",
"<rootDir>/.eslintcache"
]
,
"transformIgnorePatterns": [
"<rootDir>"
],
"coverageDirectory": "<rootDir>/coverage",
"coveragePathIgnorePatterns": [
"\\.runtime\\.js$",
"<rootDir>/test",
"<rootDir>/schemas",
"<rootDir>/node_modules"
],
"testEnvironment": "node",
"coverageReporters": [
"json"
]
}
}
结论
Vue2编译基于的node版本必须⼤于6.11.5
Nodejs 版本5 对 ES6的⽀持度只有57% complete46% complete 但是在版本6.4.0 提升到95% complete91% complete
到版本 6.5.0 提升到99% complete99%
这也说明 webpack最低⽀持 6.11的原因。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。