npm打包失败排查的全过程
我说什么你都别信 人气:0gitlab上的ci打包失败,报错权限不足
行吧,那我手动用root看看是否能打包成功
还是打包失败,报错
sh: 1: vue-cli-service: not found
没有找到node_modules下的vue-cli-service
使用find命令查找项目目录 发现并没有找到这个命令生产,难道是安装依赖的时候,没有成功吗?
我发现,项目目录下,并没有像往常一样生成一个node_modules目录。难道是把依赖安装到全局了吗?
1.查看是否安装有全局依赖
##查看全局下,是否有自己安装的包 npm root -g /data/opt/node-v14.17.6-linux-x64/lib/node_modules
显示有全局依赖路径
2.查看npm配置信息
## 查看npm配置 npm config list ; "user" config from /root/.npmrc registry = "https://registry.npm.taobao.org/" ; node bin location = /data/opt/node-v14.17.6-linux-x64/bin/node ; node version = v14.17.6 ; npm local prefix = /home/gitlab-runner/builds/abs-d ; npm version = 8.12.2 ; cwd = /home/gitlab-runner/builds/abs-d ; HOME = /root ; Run `npm config ls -l` to show all defaults.
global = false,意思局部安装,如果全局的话为true
3.修改配置信息,不知道为什么我这里设置局部失败,,,不管了
npm config set global false ## 设置全局为false npm config list ; "user" config from /root/.npmrc false = "" global = true registry = "https://registry.npm.taobao.org/" ; node bin location = /data/opt/node-v14.17.6-linux-x64/bin/node ; node version = v14.17.6 ; npm local prefix = /home/gitlab-runner/builds/abs-d ; npm version = 8.12.2 ; cwd = /home/gitlab-runner/builds/abs-d ; HOME = /root ; Run `npm config ls -l` to show all defaults.
4.重新npm install 安装依赖
npm install --global npm changed 14 packages in 2s 11 packages are looking for funding run `npm fund` for details
没有报错,但是依旧是没有node_module目录
项目目录下生成了一个 package-lock.json 文件,将文件删除再进行强制清除缓存
rm -f package-lock.json npm cache clean --force npm WARN using --force Recommended protections disabled.
清除缓存的时候又报错了...行吧兵来将挡吧。
网上的说法是:因为npm版本太高而导致。指定npm版本安装
npm install npm@6.14.10 -g removed 63 packages, and changed 97 packages in 5s 3 packages are looking for funding run `npm fund` for details
再确定删除package-lock.json下强制清除缓存
npm cache clean --force npm WARN using --force I sure hope you know what you are doing.
得了 没有报错了,npm install试试
npm install npm WARN lifecycle vue-demi@0.13.1~postinstall: cannot run in wd vue-demi@0.13.1 node ./scripts/postinstall.js (wd=/home/gitlab-runner/builds/aas-d/node_modules/vue-demi) npm WARN lifecycle core-js@3.23.1~postinstall: cannot run in wd core-js@3.23.1 node -e "try{require('./postinstall')}catch(e){}" (wd=/home/gitlab-runner/builds/aas-d/node_modules/core-js) + aas-b@0.1.0 added 205 packages from 139 contributors and updated 1 package in 33.812s ╭────────────────────────────────────────────────────────────────╮ │ │ │ New major version of npm available! 6.14.10 -> 8.12.2 │ │ Changelog: https://github.com/npm/cli/releases/tag/v8.12.2 │ │ Run npm install -g npm to update! │ │ │ ╰────────────────────────────────────────────────────────────────╯
行了终于有node_module目录了
总结
加载全部内容