项目如何安装本地tgz包并配置局部registry

一、判断包来源是否正确

1. 检查url

shell 复制代码
curl <registry_url>

2. 查看包是否存在

shell 复制代码
npm view <package_name> --registry=<registry_url>

二、局部registry配置步骤:

1. 全局配置

如果你希望对所有项目生效,可以将这行配置添加到全局.npmrc 文件中。全局 .npmrc文件通常位于以下路径:

  • Windows: C:\Users\<YourUsername>\.npmrc

添加内容:

ini 复制代码
@sdp.nd:registry=http://registry.npm.sdp.nd

2. 项目级配置

如果你只希望对当前项目生效,可以在项目根目录下创建或编辑 .npmrc 文件(与 package.json同级)。

添加内容:

ini 复制代码
@sdp.nd:registry=http://registry.npm.sdp.nd

3. 验证配置

配置完成后,可以运行以下命令验证:

sh 复制代码
npm config get @sdp.nd:registry

如果输出为 http://registry.npm.sdp.nd,说明配置成功。

4. 登录私有仓库(如果需要)

如果私有仓库需要身份验证,运行以下命令登录:

sh 复制代码
npm login --registry=http://registry.npm.sdp.nd [email protected]

输入用户名、密码和邮箱完成登录。


三、安装该SDK

执行以下命令,可以看到所有@sdp.nd的包从http://registry.npm.sdp.nd下载,其它包则从全局默认的registry下载

sh 复制代码
npm install --verbose

$ npm install --verbose

npm verb cli D:\node\node.exe D:\node\node_modules\npm\bin\npm-cli.js

npm info using [email protected]

npm info using [email protected]

npm verb title npm install

npm verb argv "install" "--loglevel" "verbose"

npm verb logfile logs-max:10 dir:C:\Users\Administrator\AppData\Local\npm-cache_logs\2025-03-29T12_55_13_064Z-

npm verb logfile C:\Users\Administrator\AppData\Local\npm-cache_logs\2025-03-29T12_55_13_064Z-debug-0.log

npm http fetch GET 200 http://registry.npm.sdp.nd/@sdp.nd%2Fnd-uc-sdk 170ms (cache revalidated)

npm http fetch GET 200 http://registry.npm.sdp.nd/@sdp.nd%2Frequest-adapter-waf 66ms (cache revalidated)

npm http fetch GET 200 https://registry.npmjs.org/crypto-js 836ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/nd-base64 849ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/lodash 987ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/nd-md5s 1054ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/@babel%2Fruntime 1061ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/nd-datetime 1120ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/nd-uri-parser 1322ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/@gem-mine%2Frequest 1441ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/axios 259ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/regenerator-runtime 275ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/@gem-mine%2Frequest-adapter-xhr 546ms (cache updated)

npm http fetch GET 200 https://registry.npmjs.org/follow-redirects 263ms (cache updated)

npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 295ms

npm http fetch GET 200 http://registry.npm.sdp.nd/@sdp.nd/nd-uc-sdk/download/@sdp.nd/nd-uc-sdk-1.9.34.tgz 346ms (cache miss)

一般上述命令能够安装成功,如果不能,也可以下载包的.tgz文件到本地,运行如下安装命令即可:

sh 复制代码
npm install ./*.tgz --save
相关推荐
江城开朗的豌豆37 分钟前
Vue组件CSS防污染指南:让你的样式乖乖“宅”在自家地盘!
前端·javascript·vue.js
江城开朗的豌豆1 小时前
Vue组件花式传值:祖孙组件如何愉快地聊天?
前端·javascript·vue.js
拉不动的猪2 小时前
pc和移动页面切换的两种基本方案对比
前端·javascript·vue.js
Hilaku2 小时前
前端日志调试也能专业化?我们这样设计日志系统
前端·javascript
花果山总钻风2 小时前
Debian 编译安装 ruby3.2
前端·javascript·debian
BUG收容所所长3 小时前
深入理解 AJAX,从 XMLHttpRequest 到现代 Fetch API
前端·javascript·ajax
Sun_light3 小时前
「一文看懂 JS 深浅拷贝,彻底告别面试踩坑!」
前端·javascript
YG9083 小时前
微信小程序页面传参乱码问题如何解决?
前端·javascript
Hilaku3 小时前
前端权限系统怎么做才不会写吐?我们项目踩过的 3 套失败方案总结
前端·javascript·vue.js
nbsaas-boot3 小时前
Vue 组件数据流与状态控制最佳实践规范
前端·javascript·vue.js