Selaa lähdekoodia

兼容node17+

seimin 1 vuosi sitten
vanhempi
commit
fb07f6e234
3 muutettua tiedostoa jossa 10 lisäystä ja 2 poistoa
  1. 2 0
      package.json
  2. 4 1
      upload/development.js
  3. 4 1
      upload/production.js

+ 2 - 0
package.json

@@ -5,6 +5,8 @@
5 5
   "scripts": {
6 6
     "build": "vue-cli-service build",
7 7
     "start": "vue-cli-service serve",
8
+    "build:17": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
9
+    "start:17": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
8 10
     "development": "node ./upload/development.js",
9 11
     "production": "node ./upload/production.js"
10 12
   },

+ 4 - 1
upload/development.js

@@ -34,7 +34,10 @@ function connectSSh() {
34 34
 }
35 35
 function runTask() {
36 36
   //打包完成
37
-  if (shell.exec(`npm run build`).code == 0) {
37
+  console.log(`当前NodeJs版本是${process.version}`);
38
+  const isNodeVersionLt17 = parseInt(process.version) < 17;
39
+  const execStr = isNodeVersionLt17 ? 'npm run build' : 'npm run build:17';
40
+  if (shell.exec(execStr).code == 0) {
38 41
     console.log("-----打包成功-----");
39 42
     //提交上传
40 43
     connectSSh();

+ 4 - 1
upload/production.js

@@ -34,7 +34,10 @@ function connectSSh() {
34 34
 }
35 35
 function runTask() {
36 36
   //打包完成
37
-  if (shell.exec(`npm run build`).code == 0) {
37
+  console.log(`当前NodeJs版本是${process.version}`);
38
+  const isNodeVersionLt17 = parseInt(process.version) < 17;
39
+  const execStr = isNodeVersionLt17 ? 'npm run build' : 'npm run build:17';
40
+  if (shell.exec(execStr).code == 0) {
38 41
     console.log("-----打包成功-----");
39 42
     //提交上传
40 43
     connectSSh();