{"_id":"01_imooc-test","_rev":"1-bbf47c42e019948f8ba34b20f3d938a0","name":"01_imooc-test","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"01_imooc-test","version":"1.0.0","description":"npm login 或者 npm adduser 之后 遇见 Public registration is not allowed","bin":{"imooc-test":"bin/index.js"},"main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":"","license":"ISC","_id":"01_imooc-test@1.0.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"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"}]},"_npmUser":{"name":"coderyzj","email":"2072678306@qq.com"},"directories":{},"maintainers":[{"name":"coderyzj","email":"2072678306@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/01_imooc-test_1.0.0_1697760489939_0.12970911007346508"},"_hasShrinkwrap":false},"1.0.1":{"name":"01_imooc-test","version":"1.0.1","description":"npm login 或者 npm adduser 之后 遇见 Public registration is not allowed","bin":{"imooc-test":"bin/index.js"},"main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","start":"node bin/index.js"},"author":"","license":"ISC","dependencies":{"02_imooc-test-lib":"^1.1.0"},"gitHead":"45c6bbfcea36e3d94049ea6313f9e8923a650f73","_id":"01_imooc-test@1.0.1","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-NYORlbj66W+JqO2vFViIgmUvGSh/NZwuTQ8zuY/ds2nElPW/tMc/Ir5TYPYnVOrKvi7gaGedH9Lqd0gk1vNMBA==","shasum":"f8115162ef6d66d11fd9ab126ea915a80255ddef","tarball":"https://registry.npmjs.org/01_imooc-test/-/01_imooc-test-1.0.1.tgz","fileCount":3,"unpackedSize":5372,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC62P4ldZoUMON5ovMokF4d5xU4E/QBVVlI7iGotNWYLAIgd/vbaJsyGtlcF8SHXfFnWl3sLajs8/GcncIMF9s0hE0="}]},"_npmUser":{"name":"coderyzj","email":"2072678306@qq.com"},"directories":{},"maintainers":[{"name":"coderyzj","email":"2072678306@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/01_imooc-test_1.0.1_1697778289201_0.43327204936142527"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-20T00:08:09.938Z","1.0.0":"2023-10-20T00:08:10.243Z","modified":"2023-10-20T05:04:49.566Z","1.0.1":"2023-10-20T05:04:49.390Z"},"maintainers":[{"name":"coderyzj","email":"2072678306@qq.com"}],"description":"npm login 或者 npm adduser 之后 遇见 Public registration is not allowed","license":"ISC","readme":"# 无法登录的问题\r\n\r\nnpm login 或者 npm adduser 之后 遇见 Public registration is not allowed\r\n\r\n```shell\r\nnpm notice Log in on https://registry.npm.taobao.org/\r\nUsername: coderyzj\r\nPassword: npm ERR! code E403\r\nnpm ERR! 403 403 Forbidden - PUT https://registry.npmmirror.com/-/user/org.couchdb.user:coderyzj - [FORBIDDEN] Public registration is not allowed\r\nnpm ERR! 403 In most cases, you or one of your dependencies are requesting\r\nnpm ERR! 403 a package version that is forbidden by your security policy, or\r\nnpm ERR! 403 on a server you do not have access to.\r\n\r\nnpm 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\r\n```\r\n\r\n其实是因为 npm 镜像地址有问题 使用下方指令 将镜像切回即可正确完成登录操作\r\n\r\n```shell\r\nnpm config set registry https://registry.npmjs.org/\r\n```\r\n\r\n注：由于上面的 registry 地址为服务器在国外，访问速度可能会比较慢，由此可能会导致链接超时问题\r\n\r\n# 发布包\r\n\r\n1. 使用 npm login 登录帐号(只需要登录一次，后续直接执行 npm publish 发布即可)\r\n2. 使用 npm publish 发布当前目录下的项目\r\n\r\n然后就可以在 https://www.npmjs.com/ 上搜索到当前项目的包名（package.json 中设置的 name 字段值）\r\n\r\n# 安装并使用自己发布的包\r\n\r\n- 全局安装自己发布的包\r\n  - 测试 package.json 中的 bin 字段中设置的命令是否有被成功添加到环境变量中\r\n  - 测试 该命令对应的软链接文件是否有被创建（存放于 nodejs 目录或者 nodejs/bin 目录下）\r\n\r\n```shell\r\n# 全局安装包\r\nnpm install -g 01_imooc-test\r\n\r\n# 在变量变量中查找 imooc-test 命令（软链接文件）\r\n# mac\r\nwhich imooc-test\r\n# windows\r\nwhere imooc-test\r\n```\r\n\r\n- 在命令行输入 imooc-test 然后回车\r\n  可以发现 package.json 中的 bin 字段中配置的 imooc-test 命令映射的文件被成功执行\r\n\r\n# 在本地引用另一个尚未发布的包 imooc-test-lib\r\n\r\n- 首先，进入到 imooc-test-lib 项目根路径下，执行`npm link`将 bin 字段中配置的命令添加到环境变量中，并生成软链接文件\r\n- 然后，进入到 imooc-test 项目根路径下，执行`npm link imooc-test-lib`将 imooc-test-lib 项目添加到当前项目的 node_modules 目录下\r\n- 然后，需要在 package.json 的 devDependencies 字段中添加 imooc-test-lib 项目的依赖\r\n- 最后就可以通过导入的方式使用 imooc-test-lib 项目中的方法了\r\n\r\n# 将本地的包 imooc-test-lib 发布到 npm 上, 并在 imooc-test 项目中引用\r\n\r\n- 首先，进入到 imooc-test-lib 项目根路径下，执行`npm login`登录 npm 账号\r\n- 然后，执行`npm publish`发布包\r\n- 中间步骤：如果之前执行了`npm link imooc-test-lib`将 imooc-test-lib 项目添加到当前项目的 node_modules 目录下，需要先执行`npm unlink imooc-test-lib`将其移除\r\n  同时，需要执行`npm remove -g imooc-test-lib`将其从全局移除\r\n- 最后，进入到 imooc-test 项目根路径下，执行`npm install imooc-test-lib`安装包\r\n- 然后，就可以通过导入的方式使用 imooc-test-lib 项目中的方法了\r\n","readmeFilename":"README.md"}