Shell命令配置
export TARGET_PATH=/www/wwwroot/retail/store
#第一次构建时需要install
#npm i
#执行构建
npm run build
#删除原构建文件
rm -f dist.tar.gz
#压缩文件
tar -czf dist.tar.gz dist
#移动文件到目标路径
cp dist.tar.gz $TARGET_PATH/
#执行部署操作
sh $TARGET_PATH/deploy.sh
问题描述
部署时,报如下错误
- Building for production…
ERROR TypeError: Cannot read property ‘modulePath’ of null
TypeError: Cannot read property ‘modulePath’ of null
…
…
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cube-ui-party-v@0.1.0 build:vue-cli-service build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cube-ui-party-v@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-03-04T09_33_33_736Z-debug.log
Build step ‘Execute shell’ marked build as failure
Finished: FAILURE
原因分析
项目中,增加一个复制粘贴的功能,引入了clipboard.js,而node_module中没有对应的modulePath,因为npm i 被我注释掉了,部署时,没有npm install clipboard --save
问题解决
shell中解除 npm i 的注释,重新生成node_module
以目前的水平,只能想到这种解决方式,欢迎各位大佬如有更便捷的方式,请交流指正。