Jenkins 部署 vue 项目 npm install 报错
用 Jenkins 部署项目时,经常报错,差不多 5,6 次报错一次
记录了2次的报错信息如下:
第一次报错:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
第二次报错:
npm ERR! path /opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink
npm ERR! Error: EACCES: permission denied, unlink '/opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli'
npm ERR! { [Error: EACCES: permission denied, unlink '/opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli']
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, unlink '/opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! '/opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli' },
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, unlink \'/opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! '/opt/test_workspace/workspace/devhm5_front_h5/node_modules/.bin/uniapp-cli',
npm ERR! parent: 'weimai-xiaochengxu' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dev_test/.npm/_logs/2019-08-06T09_57_35_402Z-debug.log
Build step 'Execute shell' marked build as failure
SSH: Connecting from host [hm5sonar]
SSH: Connecting with configuration [hm5dev_test] ...
SSH: EXEC: STDOUT/STDERR from command [cd /opt/test_workspace && /bin/bash hm5dev_front.sh h5] ...
seccuess
SSH: EXEC: completed after 200 ms
SSH: Disconnecting configuration [hm5dev_test] ...
SSH: Transferred 0 file(s)
Finished: FAILURE
因为没有定位到原因,只能手动删除 node_moudles
在各论坛找到说 "权限不够" 推荐使用: 获取最高权限
npm install --unsafe-perm=true --allow-root
可是只是偶尔出现这个问题,不是必现的,当删除掉 node_moudles 后再次部署不会报错 , 那时也没有用到最高权限
求大佬解惑 ~
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
说明你这个机器环境,同时多个用户在使用,如果某次是root用户触发的
npm install -g
则会导致 npm 全局目录下某文件夹权限修改为root,这个时候另一个非root用户也在操作同一个 path 自然会出现权限问题。