首页 > 编程知识 正文

npm package打包失败,npm package怎么获取

时间:2023-05-05 03:09:50 阅读:271793 作者:2764

npm 拉取git仓库作为package包使用

用于不发包,又没有私有仓库,可以用这样的方式取读取包。
读取方式:
import pkgA from “pkgA”

const pkgA = require(“pkgA”)

注意:如果需要构建的话,那么构建的目录也要传到仓库,比如dist,如果忽略了,包拉取后无法正常通过main:"xxx.js"使用

http方式:如果要验证会弹出用户名和密码
git+https://github.com/nolonger21/fe-cli-app-example.git

ssh方式:如果要验证直接读取本地密钥
git+ssh://git@github.com:nolonger21/fe-cli-app-example.git#master

{ "scripts": { "pkgA": "yarn add git+ssh://git@github.com:nolonger21/fe-cli-app-example.git#master" }, "dependencies": { "pkgA": "git+ssh://git@github.com:nolonger21/fe-cli-app-example.git#master" }}

Example:

npm install git+ssh://git@github.com:npm/cli.git#v1.0.27npm install git+ssh://git@github.com:npm/cli#pull/273npm install git+ssh://git@github.com:npm/cli#semver:^5.0npm install git+https://isaacs@github.com/npm/cli.gitnpm install git://github.com/npm/cli.git#v1.0.27GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/cli.git

参考:https://docs.npmjs.com/cli/v7/commands/npm-install

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。