npm access grant: team is required and must be of type string

cli
triaged

(Morgan Touverey Quilling) #1

What I Wanted to Do

I’d like to grant read-write access to the sweetalert2 team on my package @toverux/ngx-sweetalert2 (btw, my readme isn’t showing on the npm website). For that, I’ve used this command: npm access grant read-write sweetalert2 with the library’s directory as the cwd.

I’ve also tried with an explicit package name: npm access grant read-write sweetalert2 @toverux/ngx-sweetalert2

What Happened Instead

It seems to me that the CLI doesn’t parses my arguments correctly, unless I’m not understanding the usage doc:

morgan@anthracite /home/morgan/Documents/Projets/ngx-sweetalert2                                     master
⚡ npm access grant read-write sweetalert2
npm ERR! team is required and must be of type string
npm ERR! 
npm ERR! Usage:
npm ERR! npm access public [<package>]
npm ERR! npm access restricted [<package>]
npm ERR! npm access grant <read-only|read-write> <scope:team> [<package>]
npm ERR! npm access revoke <scope:team> [<package>]
npm ERR! npm access ls-packages [<user>|<scope>|<scope:team>]
npm ERR! npm access ls-collaborators [<package> [<user>]]
npm ERR! npm access edit [<package>]

Platform Info

morgan@anthracite /home/morgan/Documents/Projets/ngx-sweetalert2                                     master
⚡ npm --versions
{ 'ngx-sweetalert2-repository': '0.0.0-unreleased-demo-project',
  npm: '6.4.1',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.12.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.35',
  zlib: '1.2.11' }

morgan@anthracite /home/morgan/Documents/Projets/ngx-sweetalert2                                     master
⚡ node -p process.platform
linux

Thanks for your time and help!


(Lars Willighagen) #2

You need to add which org/user scope you want to change the team for, as you can have multiple. So the correct command would be (in the package dir):

npm access grant read-write toverux:sweetalert2

Or, from anywhere:

npm access grant read-write toverux:sweetalert2 @toverux/sweetalert2

Note the added toverux: before the team.


(Kat Marchán) #3

This is fixed by https://github.com/npm/cli/pull/2, too. Original is a support issue.


(Morgan Touverey Quilling) #4

Sorry, but it doesn’t seem to be enough:

morgan@anthracite /home/morgan/Documents/Projets/sweetalert2                             typed-argstoparams
⚡ npm access grant read-write toverux:sweetalert2 @toverux/sweetalert2
npm ERR! code E404
npm ERR! 404 Team not found : -/team/toverux/sweetalert2/package

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/morgan/.npm/_logs/2018-11-08T22_09_06_166Z-debug.log

morgan@anthracite /home/morgan/Documents/Projets/sweetalert2                             typed-argstoparams
⚡ cat /home/morgan/.npm/_logs/2018-11-08T22_00_07_015Z-debug.log      
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli   '/usr/bin/npm',
1 verbose cli   'access',
1 verbose cli   'grant',
1 verbose cli   'read-write',
1 verbose cli   'toverux:sweetalert2',
1 verbose cli   '@toverux/sweetalert2' ]
2 info using npm@6.4.1
3 info using node@v10.13.0
4 silly mapToRegistry name @toverux/sweetalert2
5 silly mapToRegistry scope (from package name) @toverux
6 verbose mapToRegistry no registry URL found in name for scope @toverux
7 silly mapToRegistry using default registry
8 silly mapToRegistry registry https://registry.npmjs.org/
9 silly mapToRegistry data { type: 'tag',
9 silly mapToRegistry   registry: true,
9 silly mapToRegistry   where: undefined,
9 silly mapToRegistry   raw: '@toverux/sweetalert2',
9 silly mapToRegistry   name: '@toverux/sweetalert2',
9 silly mapToRegistry   escapedName: '@toverux%2fsweetalert2',
9 silly mapToRegistry   scope: '@toverux',
9 silly mapToRegistry   rawSpec: '',
9 silly mapToRegistry   saveSpec: null,
9 silly mapToRegistry   fetchSpec: 'latest',
9 silly mapToRegistry   gitRange: undefined,
9 silly mapToRegistry   gitCommittish: undefined,
9 silly mapToRegistry   hosted: undefined }
10 silly mapToRegistry uri https://registry.npmjs.org/@toverux%2fsweetalert2
11 verbose request uri https://registry.npmjs.org/-/team/toverux/sweetalert2/package
12 verbose request sending authorization for write operation
13 info attempt registry request try #1 at 23:00:05
14 verbose request using bearer token for auth
15 verbose request id 0a9661f1c9ceeb74
16 http request PUT https://registry.npmjs.org/-/team/toverux/sweetalert2/package
17 http 404 https://registry.npmjs.org/-/team/toverux/sweetalert2/package
18 verbose headers { date: 'Thu, 08 Nov 2018 22:00:06 GMT',
18 verbose headers   'content-type': 'application/json',
18 verbose headers   'content-length': '26',
18 verbose headers   connection: 'keep-alive',
18 verbose headers   'set-cookie':
18 verbose headers    [ '__cfduid=d11c11584ac7a5e466d9e5968e5847e4d1541714406; expires=Fri, 08-Nov-19 22:00:06 GMT; path=/; domain=.registry.npmjs.org; HttpOnly' ],
18 verbose headers   'cf-ray': '476b4f7de9b56373-FRA',
18 verbose headers   'expect-ct':
18 verbose headers    'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
18 verbose headers   vary: 'Accept-Encoding',
18 verbose headers   server: 'cloudflare' }
19 verbose stack Error: Team not found : -/team/toverux/sweetalert2/package
19 verbose stack     at makeError (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:329:12)
19 verbose stack     at RegClient.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:317:14)
19 verbose stack     at Request._callback (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:216:14)
19 verbose stack     at Request.self.callback (/usr/lib/node_modules/npm/node_modules/request/request.js:185:22)
19 verbose stack     at Request.emit (events.js:182:13)
19 verbose stack     at Request.<anonymous> (/usr/lib/node_modules/npm/node_modules/request/request.js:1161:10)
19 verbose stack     at Request.emit (events.js:182:13)
19 verbose stack     at IncomingMessage.<anonymous> (/usr/lib/node_modules/npm/node_modules/request/request.js:1083:12)
19 verbose stack     at Object.onceWrapper (events.js:273:13)
19 verbose stack     at IncomingMessage.emit (events.js:187:15)
20 verbose statusCode 404
21 verbose cwd /home/morgan/Documents/Projets/sweetalert2
22 verbose Linux 4.18.0-10-generic
23 verbose argv "/usr/bin/node" "/usr/bin/npm" "access" "grant" "read-write" "toverux:sweetalert2" "@toverux/sweetalert2"
24 verbose node v10.13.0
25 verbose npm  v6.4.1
26 error code E404
27 error 404 Team not found : -/team/toverux/sweetalert2/package
28 verbose exit [ 1, true ]

I assume that’s still not the good syntax, unless there’s another bug.


(Lars Willighagen) #5

Oh, I didn’t realise what you were trying to do… You’re not trying to give a team access, but an org (I didn’t check the link the first time). That makes sense then. My bad, sorry for the confusion. I suppose it would be

 npm access grant read-write sweetalert2:<team>

Where <team> is probably developers, depending on what teams are defined in that organisation. I don’t know if you can give an entire organisation access to a package, or how you would do that.