我尝试将我的github项目部署到vercel中。我的项目是用Vue构建的。顺便说一句,在vercel中构建项目时,它有很多这样的错误。
npm ERR! gyp verb extracted file from tarball node-v18.15.0/include/node/openssl/archs/VC-WIN64A/asm_avx2/include/openssl/x509v3.h
npm ERR! gyp verb extracted file from tarball node-v18.15.0/include/node/openssl/archs/VC-WIN64A/asm_avx2/include/openssl/asn1.h
npm ERR! gyp verb extracted file from tarball node-v18.15.0/include/node/openssl/archs/VC-WIN64A/asm_avx2/include/openssl/safestack.h
npm ERR! gyp verb extracted file from tarball node-v18.15.0/include/node/openssl/archs/VC-WIN64A/asm_avx2/include/openssl/lhash.h
这是vercel错误的截图。enter image description here
以下是package.json中的内容
{
"name": "aali-vue",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@emailjs/browser": "^3.11.0",
"core-js": "^3.6.5",
"isotope-layout": "^3.0.6",
"jarallax": "^1.12.8",
"node-sass": "^5.0.0",
"parallax-js": "^3.1.0",
"swiper": "^5.4.5",
"vanilla-tilt": "^1.7.2",
"vue": "^2.6.11",
"vue-awesome-swiper": "^4.1.1",
"vue-fragment": "^1.5.2",
"vue-number-animation": "^1.1.1",
"vue-router": "^3.2.0",
"vue-visibility-sensor": "^0.3.0",
"wowjs": "^1.1.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
它在本地编译并运行良好。你知道解决办法吗?
谢谢
开发环境操作系统:Windows 10专业版(19045.2965)编辑器:VS代码GitHub存储库:使用我的github帐户部署Vercel
预期结果:成功构建和部署,没有错误
1条答案
按热度按时间vtwuwzda1#
我使用yarn install而不是npm解决了这个问题。Yarn比npm更好地解决依赖问题。
它的步伐就像跟随。
当您在vercel中使用您的帐户登录时,您可以转到设置/常规/构建和开发设置。
Setting/General/Build & Development Settings您可以在此处看到4个设置为禁用的输入字段。请激活覆盖第三个称为
Install Command
的,并输入yarn install
。并点击保存按钮。并尝试在部署页中重新部署。通常情况下,它会解决正常的依赖性问题。
在我的情况下,仍然发生了与gyp相关的构建错误。我猜这将与node和node-sass版本有关。
我们还可以在vercel中更改节点版本。转到Setting/General/Node.js版本。你可以看到你的网站的节点版本。Node version setting
在我的例子中,node版本是18,package.json中的node-sass版本是5.0.0。所以,他们不匹配。我将节点更改为16.x,将node-sass更新为6.0.0,并再次部署。
是的!它起作用了。Deployment successfully