npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

01_imooc-test

v1.0.1

Published

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

Downloads

5

Readme

无法登录的问题

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 项目中的方法了