hadamard
hadamard

Reputation: 443

cant publish npm package to gitlab registry

I am trying a simple setup to publish a node package into gitlabs package registry. I created a project from the gitlabs node express template. But when I run npm publish I am getting the following error

npm notice 
npm notice 📦  @root-group/[email protected]
npm notice === Tarball Contents === 
npm notice 318B  .gitlab-ci.yml              
npm notice 100B  .gitpod.yml                 
npm notice 8B    .node-version               
npm notice 2.2kB CONTRIBUTING.md             
npm notice 201B  Dockerfile                  
npm notice 1.1kB LICENSE                     
npm notice 822B  README.md                   
npm notice 1.1kB app.js                      
npm notice 1.6kB bin/www                     
npm notice 962B  jenkinsfile                 
npm notice 407B  package.json                
npm notice 111B  public/stylesheets/style.css
npm notice 205B  routes/index.js             
npm notice 203B  routes/users.js             
npm notice 232B  test/test.js                
npm notice 84B   views/error.pug             
npm notice 66B   views/index.pug             
npm notice 125B  views/layout.pug            
npm notice === Tarball Details === 
npm notice name:          @root-group/prj                         
npm notice version:       0.0.0                                   
npm notice filename:      root-group-prj-0.0.0.tgz                
npm notice package size:  4.7 kB                                  
npm notice unpacked size: 9.8 kB                                  
npm notice shasum:        a4c2b35dc8e70e2bc62bdc3cc41eacd18ede49d8
npm notice integrity:     sha512-B8urHXCGTYsE9[...]g8CiL0dYVJA+A==
npm notice total files:   18                                      
npm notice 
npm notice Publishing to https://gitlab.com/api/v4/projects/<project_id>/packages/npm/ with tag latest and default access
npm ERR! code EPRIVATE
npm ERR! This package has been marked as private
npm ERR! Remove the 'private' field from the package.json to publish it.

The project where I want to upload the package to is in the following path https://gitlab.com/root-group/my/path/prj. So prj is just an empty project that should act as a package registry.

The project I want to upload looks as follows.
package.json

    {
  "name": "@root-group/prj",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "test": "mocha --exit"
  },
  "dependencies": {
    "cookie-parser": "^1.4.5",
    "debug": "^4.3.1",
    "express": "^4.17.1",
    "http-errors": "^1.8.0",
    "morgan": "^1.10.0",
    "pug": "^3.0.2"
  },
  "devDependencies": {
    "mocha": "^9.0.0",
    "supertest": "^6.1.3"
  }
}

.npmrc

@root-group:registry=https://gitlab.com/api/v4/projects/<registry_project_id>/packages/npm/
//gitlab.com/api/v4/projects/<registry_project_id>/packages/npm/:_authToken="<access_token>"

It doesnt even matter what access token I use, the same error occurs even with a random string.

Upvotes: 2

Views: 110

Answers (1)

hadamard
hadamard

Reputation: 443

Ok that is embarassing. In the package.json was the setting private: true.

I just had to remove that.

Upvotes: 2

Related Questions