这可能会有所帮助。将这些脚本添加到
package.json文件中。
React:
"scripts": {
"start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
"build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"
}
如果你使用的是
React.js
,并且你在
Windows
平台上编程,可以使用以下语法将脚本中的
export
替换为
set
:
"scripts": {
"start": "set SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
"build": "set SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"
}
或者
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
}
Vue.js:
"scripts": {
"serve": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"lint": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint"
},
如果你正在使用 Vue.js
并且在 Windows
上,你可以在你的脚本中使用 set
代替 export
,如下所示:
"scripts": {
"serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"lint": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint"
},
或者
"scripts": {
"serve": "vue-cli-service --openssl-legacy-provider serve",
"build": "vue-cli-service --openssl-legacy-provider build",
"lint": "vue-cli-service --openssl-legacy-provider lint"
},
Angular:
"scripts": {
"start": "set NODE_OPTIONS=--openssl-legacy-provider && gulp buildDev && ng serve ",
"publish": "set NODE_OPTIONS=--openssl-legacy-provider && gulp build && ng build --prod",
},
npm run serve
- Pierre Henry