Catalog npm
Back to packageRELEASE DETAILS

1.0.0

npm

01_imooc-test

npm login 或者 npm adduser 之后 遇见 Public registration is not allowed

Published20 Oct 2023
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

无法登录的问题

npm login 或者 npm adduser 之后 遇见 Public registration is not allowed

npm notice Log in on https://registry.npm.taobao.org/
Username: coderyzj
Password: npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmmirror.com/-/user/org.couchdb.user:coderyzj - [FORBIDDEN] Public registration is not allowed
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

npm ERR! A complete log of this run can be found in: C:\Users\20726\AppData\Local\npm-cache\_logs\2023-10-19T23_44_36_284Z-debug-0.log

其实是因为 npm 镜像地址有问题 使用下方指令 将镜像切回即可正确完成登录操作

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

注:由于上面的 registry 地址为服务器在国外,访问速度可能会比较慢,由此可能会导致链接超时问题

发布包

  1. 使用 npm login 登录帐号(只需要登录一次,后续直接执行 npm publish 发布即可)
  2. 使用 npm publish 发布当前目录下的项目

然后就可以在 https://www.npmjs.com/ 上搜索到当前项目的包名(package.json 中设置的 name 字段值)

安装并使用自己发布的包

  • 全局安装自己发布的包
    • 测试 package.json 中的 bin 字段中设置的命令是否有被成功添加到环境变量中
    • 测试 该命令对应的软链接文件是否有被创建(存放于 nodejs 目录或者 nodejs/bin 目录下)
# 全局安装包
npm install -g 01_imooc-test

# 在变量变量中查找 imooc-test 命令(软链接文件)
# mac
which imooc-test
# windows
where imooc-test
  • 在命令行输入 imooc-test 然后回车 可以发现 package.json 中的 bin 字段中配置的 imooc-test 命令映射的文件被成功执行

在本地引用另一个尚未发布的包 imooc-test-lib

  • 首先,进入到 imooc-test-lib 项目根路径下,执行npm link将 bin 字段中配置的命令添加到环境变量中,并生成软链接文件
  • 然后,进入到 imooc-test 项目根路径下,执行npm link imooc-test-lib将 imooc-test-lib 项目添加到当前项目的 node_modules 目录下
  • 然后,需要在 package.json 的 devDependencies 字段中添加 imooc-test-lib 项目的依赖
  • 最后就可以通过导入的方式使用 imooc-test-lib 项目中的方法了

将本地的包 imooc-test-lib 发布到 npm 上, 并在 imooc-test 项目中引用

  • 首先,进入到 imooc-test-lib 项目根路径下,执行npm login登录 npm 账号
  • 然后,执行npm publish发布包
  • 中间步骤:如果之前执行了npm link imooc-test-lib将 imooc-test-lib 项目添加到当前项目的 node_modules 目录下,需要先执行npm unlink imooc-test-lib将其移除 同时,需要执行npm remove -g imooc-test-lib将其从全局移除
  • 最后,进入到 imooc-test 项目根路径下,执行npm install imooc-test-lib安装包
  • 然后,就可以通过导入的方式使用 imooc-test-lib 项目中的方法了

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-HkoBaELZgq4dG/ki+L8BT/GuFcyfHrNyvwdw282LAjU7Uh85QQNQtG1QLu2CpZSHUGrHwGcvcJaIkf3Pnsz9Ag==",
  "shasum": "406f61111c62bb4120a4987d9c3323050c74c3cf",
  "tarball": "https://registry.npmjs.org/01_imooc-test/-/01_imooc-test-1.0.0.tgz",
  "fileCount": 3,
  "unpackedSize": 1321,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQD5YAKwGP63wC7uVZfvhRzN314AlIoMqkSVwb0k9Zme1AIhALcPg0fyQDrKLTKDk6hTgbO7UyPktqYqOVWeYynxWxEd"
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 16:47 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:574f9b8f6b70df7ab6ce72db1e239cc338303c91c686c7684e0d6e008ba6ffa5

Other collected versions

1.0.120 OctView all collected versions →