请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

npm run pub后报错

老师,在提交后,提示如下错误,到百度中也搜索了,查询不到相关问题的处理方法,请帮忙指导一下!
Enter release version:
1.0.1
Realeaing 1.0.1 - are you sure? (y/n)y
Realeaing 1.0.1 …
On branch master
nothing to commit, working tree clean
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ts-axios-rockyhu@1.0.0-dev pub: sh release.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ts-axios-rockyhu@1.0.0-dev pub 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! /Users/rockyhu/.npm/_logs/2020-02-10T13_07_47_713Z-debug.log

正在回答 回答被采纳积分+3

2回答

提问者 慕少8034756 2020-02-10 21:54:14

#!/usr/bin/env sh

set -e
echo "Enter release version:"
read VERSION
read -p "Realeaing $VERSION - are you sure? (y/n)" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
 echo "Realeaing $VERSION ..."

 # commit
 git add -A
 git commit -m "[build] $VERSION"
 npm version $VERSION --message "[release] $VERSION"
 git push origin master

 # publish 发布到npm
 # 发布前需要在终端登录npm,即执行npm login,按照引导输入即可
 npm publish
fi

0 回复 有任何疑惑可以回复我~
ustbhuangyi 2020-02-10 21:23:45

贴一下你的 release.sh 代码

0 回复 有任何疑惑可以回复我~
  • 提问者 慕少8034756 #1
    #!/usr/bin/env sh
    
    set -e
    echo "Enter release version:"
    read VERSION
    read -p "Realeaing $VERSION - are you sure? (y/n)" -n 1 -r
    echo # (optional) move to a new line
    if [[ $REPLY =~ ^[Yy]$ ]]
    then
      echo "Realeaing $VERSION ..."
    
      # commit
      git add -A
      git commit -m "[build] $VERSION"
      npm version $VERSION --message "[release] $VERSION"
      git push origin master
    
      # publish 发布到npm
      # 发布前需要在终端登录npm,即执行npm login,按照引导输入即可
      npm publish
    fi
    回复 有任何疑惑可以回复我~ 2020-02-10 21:59:10
  • 提问者 慕少8034756 #2
    我完全复制了老师的release.sh文件内容。然后重新运行 npm run pub时,由重新报错,报错信息如下:
    
    rockyhu@192 ts-axios % cat /Users/rockyhu/.npm/_logs/2020-02-10T14_01_47_347Z-debug.log
    。。。省略。。。
    18 http fetch PUT 403 https://registry.npm.taobao.org/ts-axios-rockyhu 743ms
    19 verbose stack Error: 403 Forbidden - PUT https://registry.npm.taobao.org/ts-axios-rockyhu - [no_perms] Private mode enable, only admin can publish this module
    19 verbose stack     at res.buffer.catch.then.body (/Applications/MAMP/htdocs/2019/ts-axios/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:104:15)
    19 verbose stack     at process.internalTickCallback (internal/process/next_tick.js:77:7)
    20 verbose statusCode 403
    21 verbose pkgid ts-axios-rockyhu@1.0.3
    22 verbose cwd /Applications/MAMP/htdocs/2019/ts-axios
    23 verbose Darwin 19.3.0
    24 verbose argv "/usr/local/bin/node" "/Applications/MAMP/htdocs/2019/ts-axios/node_modules/.bin/npm" "publish"
    25 verbose node v11.2.0
    26 verbose npm  v6.13.7
    27 error code E403
    28 error 403 403 Forbidden - PUT https://registry.npm.taobao.org/ts-axios-rockyhu - [no_perms] Private mode enable, only admin can publish this module
    回复 有任何疑惑可以回复我~ 2020-02-10 22:14:15
  • 提问者 慕少8034756 #3
    老师,我的问题已解决。总结如下:
    (1)每次提交的时候,必须要有改动,自动化部署脚本release.sh脚本中的git命令才能执行成功。
    (2)需切换到npmjs源,
    npm config set registry https://registry.npmjs.org/
    回复 有任何疑惑可以回复我~ 2020-02-10 22:43:28

相似问题

登录后可查看更多问答,登录/注册

问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信