npm i --save https://github.com/qiu8310/jquery-legacy.git # npm 里有个 jquery-legacy 现在jq的路径有问题,所以直接使用另一个fork的git仓库 npm install jquery@2 # 现在不加版本默认安装3了 然后js文件里 require("jsdom").env("", function(err, window) { if (err) { return console.error(err); } var jquery2 = require('jquery')(window); console.log(jquery2.fn.jquery); var jquery1 = require('jquery-legacy')(window); console.log(jquery1.fn.jquery); }); 参考: https://docs.npmjs.com/cli/in...
然后js文件里
参考:
https://docs.npmjs.com/cli/in...