GitLab 配置的前端工程项目自动部署,每次提交代码后,自动执行git pull origin dev
命令,然后 npm install
安装依赖, 最后执行 npm run build
命令打包文件到服务器指定位置.
有次提交后出现以下错误,本地一切操作OK,自动部署 npm install
报错
... * branch dev -> FETCH_HEAD Updating 81cc1fc..540bd81 Fast-forward .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) npm info it worked if it ends with ok npm info using npm@5.0.3 npm info using node@v8.1.2 npm info lifecycle wewo-app-engine@~preinstall: wewo-app-engine@ Unhandled rejection RangeError: Maximum call stack size exceeded at Array.forEach (native) at exports.create (/usr/local/lib/node_modules/npm/lib/install/node.js:33:25) at /usr/local/lib/node_modules/npm/lib/install/node.js:36:14 at Array.forEach (native) at exports.create (/usr/local/lib/node_modules/npm/lib/install/node.js:33:25) at /usr/local/lib/node_modules/npm/lib/install/node.js:36:14 at Array.forEach (native) at exports.create (/usr/local/lib/node_modules/npm/lib/install/node.js:33:25) at normalizeTree (/usr/local/lib/node_modules/npm/lib/install.js:377:5) at Array.forEach (native) at normalizeTree (/usr/local/lib/node_modules/npm/lib/install.js:379:19) at Array.forEach (native) at normalizeTree (/usr/local/lib/node_modules/npm/lib/install.js:379:19) at Array.forEach (native) at normalizeTree (/usr/local/lib/node_modules/npm/lib/install.js:379:19) at Array.forEach (native) npm ERR! cb() never called! npm ERR! This is an error with npm itself. Please report this error at: npm ERR! <https://github.com/npm/npm/issues> npm ERR! A complete log of this run can be found in: npm ERR! /atlas/home/test/.npm/_logs/2018-07-04T10_34_30_817Z-debug.log ERROR: Job failed: exit status 1
由于提交的前端代码目录结构进行了调整,以及相关依赖进行了修改, node_modules 文件混乱导致出现问题, 手动删除服务器 node_modules 文件夹,重新执行自动部署OK.