node.js - 如何发布 NPM Scoped Packages/NPM scope not found?

标签 node.js npm npm-publish

我想开始将 npm 包发布到一个范围。我是否需要以范围作为我的用户名注册为用户?例如,如果我创建这样的包:

    ole@MKI:~/firstpackage$ npm init

    Use `npm install <pkg> --save` afterwards to install a package and
    save it as a dependency in the package.json file.

    Press ^C at any time to quit.
    name: (firstpackage) @npmtestscope/firstpackage
    version: (1.0.0) 
    description: 
    entry point: (index.js) 
    test command: 
    git repository: 
    keywords: 
    author: 
    license: (ISC) 
    About to write to /home/ole/deletethis/package.json:

    {
      "name": "@npmtestscope/firstpackage",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC"
    }


    Is this ok? (yes) 

    ole@MKI:~/firstpackage$ touch README.md
    ole@MKI:~/firstpackage$ npm publish

这是结果:

npm ERR! 404 Scope not found : @npmtestscope/firstpackage

那么我需要做什么才能让 npm 找到作用域?

最佳答案

如果您想使用名称 @npmtestscope/firstpackage 在 npm 上发布包,您需要确保命名空间 @npmtestscope 存在于 npm 上.要创建该命名空间,您需要 create an organization on npm名称为 npmtestscope

创建组织后,您可以通过执行 npm publish --access public 发布名为 @npmtestscope/firstpackage 的包。

注意:要为属于 npm 组织的包运行 npm publish,您需要以该组织的成员身份登录计算机。您可以通过执行 npm login 来做到这一点。 npm whoami 命令将显示与当前登录关联的用户名。

关于node.js - 如何发布 NPM Scoped Packages/NPM scope not found?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43824012/

相关文章:

node.js - 使用 typescript 表达无法查找 View 目录

node.js - 编辑 node.js 核心文件不起作用

node.js - 创建 react 应用程序npm启动错误: Cannot find module '@webassemblyjs/ast'

node.js - 在 Nexus 中获取最新版本的 Node 包

node.js - 带 Node 的 ECMAScript 国际化 API

node.js - 将 socket.io 更新到 1.0 版本时出现多个轮询请求(HTTP 错误 400)

typescript - Vue 库类型

node.js - 未满足的对等依赖性 angular 2.3.0 rxjs zone.js

npm - 运行 npmpublish 没有错误,但看不到更新的包

node.js - 发布的 npm 包不可见 npm