npm 直接安装 GitHub/GitLab 仓库代码及 npm link 本地调试

一、npm 直接安装 GitHub/GitLab 仓库代码

语法

npm install <git remote url>

示例

命令:

npm i git@github.com:mazeyqian/mazey.git -S
# 或
npm i https://github.com/mazeyqian/mazey.git -S
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "mazey": "github:mazeyqian/mazey",
  }
}
# 或
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "mazey": "git+ssh://git@gitlab.mazey.net:mazeyqian/mazey.git"
  }
}

语法

npm link (in package dir)
npm link [<@scope>/]<pkg>[@<version>]

alias: npm ln

示例

npm 包:mazey-sdk
项目文件夹名:mazey-project

# 进入本地 npm 文件
cd ~/mazey-sdk
npm link
# 进入项目文件
cd ~/mazey-project
npm link mazey-sdk

示例

npm 包:mazey-sdk
项目文件夹名:mazey-project

# 进入项目文件
cd ~/mazey-project
npm unlink --no-save mazey-sdk
# 进入本地 npm 文件?
cd ~/mazey-sdk
npm unlink

版权声明

本博客所有的原创文章,作者皆保留版权。转载必须包含本声明,保持本文完整,并以超链接形式注明作者后除和本文原始地址:https://blog.mazey.net/2616.html

(完)

posted @ 2022-03-03 11:36  后除  阅读(311)  评论(0编辑  收藏  举报