npm

npm 发布插件

账号: zouyu01sz 邮箱:10450321607@qq.com 密码:sp9

# 1. 发布到 npm 所需要的资料

https://www.modb.pro/db/250666

cd you project
1. npm login

2. 输入用户名和密码已经邮箱,会收到邮箱验证码
3. 输入完邮箱验证码,
4. 使用npm publish发布
出现  + vue3-screen-shot@1.0.2  代表发布成功啦

5. 删除指定版本npm unpublish mj-calculation@1.0.2,成功会输出删除的版本号,对应服务器也会删除。
6. 撤销已发布的包npm unpublish mj-calculation使用的命令。
7. 强制撤销已发布的包npm unpublish mj-calculation --force使用的命令。

# 2. 常见错误

# 2.1. npm 错误!405 方法不允许,解决方案。新建 .npmrc 文件

strict-ssl=false
registry=https://registry.npmjs.org

或者:npm config set registry https://registry.npmjs.org

# 2.2. npm ERR 404 You should bug the author to publish it (or use the name yourself)

前提已经发布

解决办法:就是切换镜像
npm config set registry http://registry.npm.taobao.org

# 2.3. npm login 后 NPM 包发布过程中报错——`npm ERR! Unexpected token < in JSON at position 0 while parsing near ‘<!DOCTYPE HTML P

# 通过npm config set registry https://registr.npmjs.org切换为npm镜像;
# // 顺序执行如下代码即可
npm config get proxy
npm config get https-proxy
npm config set registry https://registry.npmjs.org

# 2.4. npm login 无法登录

错误原因: npm error network request to https://registry.npmjs.org/-/v1/login failed, reason: read ECONNRESET

解决:
npm config set registry http://registry.npmjs.org/
npm config rm proxy
npm config rm https-proxy

# 3. 自动更改 package.json version 版本

npm version major #结果0.0.1->1.0.0
npm version minor #结果0.0.1->0.1.0
npm version patch #结果0.0.1->0.0.2
npm version prerelease #结果0.0.1 -> 0.0.2-0
npm version prerelease --preid=beta  #结果0.0.1->0.0.2-beta.0
npm version prerelease 0.0.2-beta.0  #结果0.0.1->0.0.2-beta.0
  • major:代表主版本号,通常在需要提交不能向下兼容的情况下对该版本号进行升级

  • minor:代表次版本号,通常在新增功能时才对该版本号进行升级

  • patch:代表修复版本号,升级该版本号通常代表修复一些 bug,但没有新增功能或者存在不向下兼容的功能

  • prerelease:带有该版本号的包通常表示在测试阶段,尚未稳定,通常不建议用户安装

上次更新: