发布一个自己的NPM包

技术 解决方案 随笔

Nginx

2020-06-23 19:25:48

383

作者:黑夜男神

npm账号

用户名: wangxiping
密码: Wang101029xixi.

npm包: wang-sum-number 已经上传

github:https://github.com/darkNightMan/sum-number.git

npm get registry
# 如果不是这个地址https://registry.npmjs.org  需要设置官网源
npm config set registry https://registry.npmjs.org

注册npm账号(有账号跳过这步)

npm adduser
# Username: 用户名
# Password: 密码
# Email: 邮箱
### 创建模块

npm init

package.json 内容

{
  "name": "isnumber-lpz",
  "version": "1.0.0",
  "description": "Number\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[C\u001b[C\u001b[Cis\u001b[C\u001b[C\u001b[Number",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/lanpangzhi/isNumber-lpz.git"
  },
  "author": "lanpangzhi",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/lanpangzhi/isNumber-lpz/issues"
  },
  "homepage": "https://github.com/lanpangzhi/isNumber-lpz#readme"
}

# 创建 index.js
touch index.js

function isNumber(number) {
  number = parseFloat(number)
  return number === number && typeof number === 'number' 
}

module.exports = isNumber

登录

npm login

发布包

npm publish

评论 (0)

用户名
邮箱
评论

    Copyright © 2020 darkNightMan All Rights Reserved Pro 黔ICP备20005477号