npm 包发布

  • name

    publish必填项(version,name+verson构成唯一标识),唯一,所以publish前验证库里是否存在该名称,方式npm info  xxx 
    npm ERR! 404 'cy_test' is not in the npm registry.可以使用。
    
    • 规则:不能以.或者_开头,不能有大写字母

    • 原则上不与node模块重名,名称中不应有js/node字样,简短有意义

  • version:打包必填

  • description:是一段描述:string

  • homepage:文件地址

    "homepage": "https://github.com/owner/project#readme"
    
  • keywords:让人在npm更容易检索到你的包

 "keywords": ["ant","ui"],

- 注册/登录(npm)

(1)第一次登录要去邮箱验证下,不然会报403--In most cases, you or one of your dependencies are requesting

(2)如果是403,code E403 没权限发布 npm ERR! [no_perms] Private mode enable, only admin can

这个是你的源设置成第三方源的时候才有可能发生,比如设置了淘宝源就可能会导致该问题

npm config set registry http://registry.npmjs.org

npm login

npm init

安装 nrm

npm install nrm -g
nrm ls
nrm use npm