How to publish limited NPM packages / NPM scope not found?

I want to start publishing npm packages in a scope. Do I need to register as a user scoped as my username? Example if I create a package like this:

    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

      

This is the result:

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

      

So what do I need to do so that npm can find the area?

+3


source to share


2 answers


To create an npm organization that allows you to publish packages in your scopes, follow steps 1, 2, and 3 on this page:



https://www.npmjs.com/docs/orgs/getting-started.html

+3


source


If you want to publish a package to npm using a name @npmtestscope/firstpackage

, you need to make sure the namespace @npmtestscope

exists in npm . To create this namespace, you need to create an npm organization named npmtestscope

.

Once you've created an organization, you can publish your named package by @npmtestscope/firstpackage

running @npmtestscope/firstpackage

npm publish --access public

.



Note. To run npm publish

for a package owned by the npm organization, you must be logged on to your computer as a member of that organization. You can do this by running npm login

. The command npm whoami

will show you the username associated with the current login.

0


source







All Articles