Vue2最低支持Node版本调查

背景

确定Vue2最低支持的Node版本,可以在CI环境中,确定Node的一些信息, 是否适合后端环境共享同一个Node版本呢。

Vue2项目

https://github.com/vuejs/vue/blob/dev/package.json

调研了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.runtime.common.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/karma.dev.config.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/karma.unit.config.js",
    "test:cover": "karma start test/unit/karma.cover.config.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/karma.sauce.config.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+https://github.com/vuejs/vue.git"
  },
  "keywords": [
    "vue"
  ],
  "author": "Evan You",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/vuejs/vue/issues"
  },
  "homepage": "https://github.com/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",
    "lodash.template": "^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

https://github.com/webpack/webpack/releases?after=v5.0.0-alpha.10

从其发布的列表中,找到对应的4.28.4版本

https://github.com/webpack/webpack/archive/v4.28.4.zip

下载后查看其中的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",
    "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": "https://github.com/webpack/webpack.git"
  },
  "homepage": "https://github.com/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}/**/webpack.config.js\" \"examples/**/webpack.config.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}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
    "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}/**/webpack.config.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的原因。

From: http://www.alloyteam.com/2016/07/nodejs-native-support-of-the-es6-features/

原文地址:https://www.cnblogs.com/lightsong/p/12354324.html

时间: 2024-08-30 09:29:38

Vue2最低支持Node版本调查的相关文章

使用nvm利器,管理node版本

node.js越来越热,应用的场景也越来越多. 但也因为是开源软件,所以具备大多数开源软件都存在的“版本问题”,版本发展很快,版本前后差异性大,老系统用新版本node跑不过,全局安装的第三方组件和node版本相关造成全局版本混乱. nvm是解决这一问题的利器. nvm是node版本管理工具,主要特点: 1.可安装多版本的node. 2.灵活切换当前的node版本. 3.以沙箱方式全局安装第三方组件到对应版本的node中. 4.通过.vnmrc文件,方便灵活地指定各应用系统所需的node版本进行运

Xcode5.1.1支持低版本和image not found和Couldn&#39;t register XXXX with the bootstrap server. Error: unknown error code.

一:问题  targets中证书的设置 1.项目支持多设备(Xcode5.1.1支持低版本) 2.真机测试要确保Code Siging 设置没问题 支持的最低版本 二 :问题:image  not found Library not loaded: /System/Library/Frameworks/AdSupport.framework/AdSupport   Referenced from: /var/mobile/Applications/0083F6DD-6466-48B4-8F6D-

管理 node 版本,选择 nvm 还是 n?

来源:http://taobaofed.org/blog/2015/11/17/nvm-or-n/ 引子 我本机安装着 nvm,而 node 本来一直运行在 0.x 的老版本上.后来为了跑 ES6,我将 node 切换到 4.x 的版本,并且把老版本给删掉了. 然后我就碰到了两个问题.一是 WebStorm 报错说找不到 node 解释器了.我只好去设置里面重新设置一番解释器的路径: 在我的记忆中,WebStorm 默认不需要设置 node 路径,它会去找 /usr/local/bin,即通常的

windows下装多个node版本的方法(gnvm)

安装一个支持windows切换node版本的工具 工作中我们可能需要用到一些工具,但这些工具依赖不同版本的node环境,那我们需要来为的切换node的环境吗, window msi安装的用户需要卸载重装的循环吗? 一切都变得很好,只是因为有了GNVM mac下直接安装 n 就可以了. 而坑爹的windows却未被支持 文章主要内容来自http://shalles.github.io/blog/tools/2015/04/27/windows-nodejs-version-controller 多

【前端开发】nrm切换淘宝镜像&amp;nvm管理node版本及切换

说明:nrm是切换淘宝镜像用的,nvm是node的版本切换用的(可在自己电脑安装多个版本node,便于不同项目的支持) 一.nrm的安装及常见命令: 安装nrmnpm install -g nrm 查看镜像列表nrm ls 切换镜像nrm use taobao 在nrm添加自己的镜像地址nrm add r_name r_url 删除nrm del r_name 测试镜像的相应速度nrm test r_name 二.使用nvm管理node版本及切换 第一步:下载nvm可以到这里下载链接:https

WebGL 支持检测与已支持浏览器版本汇总

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. 是否我的浏览器支持 WebGL http://caniuse.com 在页面搜索 webgl,找到  WebGL - 3D Canvas grap

让PDF.NET支持不同版本的SQL Server Compact数据库

最近项目中需要用到嵌入式数据库,我们选用的数据开发框架是PDF.NET(http://www.pwmis.com/SqlMap/),之前的博文已经总结了让PDF.NET支持最新的SQLite,今天我们来总结一下如何让PDF.NET支持不同版本的SQL Server Compact数据库.PDF.NET支持大部分主流的数据库,SQL Server Compact也不例外,但是PDF.NET只支持SQL Server Compact 4.0,而SQL Server Compact又没有做到向下兼容,

Mac上使用brew安装nvm来支持多版本的Nodejs

brew方式 如果机器没有安装过node,那么首先brew install nvm安装nvm. 其次需要在shell的配置文件(~/.bashrc, ~/.profile, or ~/.zshrc)中添加如下内容: # For NVM export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh 注意配置的顺序,以防开启新终端,node出现找不到的情况. 重启终端,命令行下即可使用nvm,使用nvm install <version>进行对应

【Oracle】ORACLE SQL Developer不支持JAVA版本

ORACLE SQL Developer不支持JAVA版本 今天我打开 ORACLE SQL Developer准备开始练手.没有想到却给出了错误提示. 我 是安装了java JDK的而且是1.6版本的.我可能选择了bin目录下面的java.exe文件,原本觉得这样的操作应该是没有问题的结果还是出现了错误.具体错误信息如 下:不支持的java版本,不支持java 6.0发行版本1.6.0_xxx,请升级到java 6.0发行版本1.6.0_04.或者降级到java 5.0发行版本1.5.0或更高