npm publish 403 error for unpublished version, "cannot publish over the previously published versions"

registry
triaged

(Chris Dopuch) #1

What I Wanted to Do

I am trying to publish a new node module I wrote for the first time.

What Happened Instead

I get a 403 error back from npm saying You cannot publish over the previously published versions: 0.0.5. : @chrisdopuch/typescript-typings-test
I have not published this version, so I don’t know why it would give that error message (I’m up to 0.0.5 after retyring a few times). You can see that the package can’t be found here: https://www.npmjs.com/package/@chrisdopuch/typescript-typings-test

Reproduction Steps

Clone this: https://github.com/chrisdopuch/typescript-typings-test

Try to run npm version && npm publish

I’ve tried a few times now and each time it returns the same error.
I’ve tried installing the package in another project, but I get a 404 not found.

Details

Note that I am using the Windows Subsystem for Linux with Ubuntu. I am running the npm commands from the linux command line.

0 info it worked if it ends with ok
1 verbose cli [ '/home/cdopuch/.nvm/versions/node/v10.7.0/bin/node',
1 verbose cli   '/home/cdopuch/.nvm/versions/node/v10.7.0/bin/npm',
1 verbose cli   'publish',
1 verbose cli   '--access',
1 verbose cli   'public',
1 verbose cli   '--verbose' ]
2 info using npm@6.4.1
3 info using node@v10.7.0
4 verbose npm-session 0df4ffb8b2883b2f
5 verbose publish [ '.' ]
6 info lifecycle @chrisdopuch/typescript-typings-test@0.0.5~prepublish: @chrisdopuch/typescript-typings-test@0.0.5
7 info lifecycle @chrisdopuch/typescript-typings-test@0.0.5~prepare: @chrisdopuch/typescript-typings-test@0.0.5
8 info lifecycle @chrisdopuch/typescript-typings-test@0.0.5~prepublishOnly: @chrisdopuch/typescript-typings-test@0.0.5
9 info lifecycle @chrisdopuch/typescript-typings-test@0.0.5~prepack: @chrisdopuch/typescript-typings-test@0.0.5
10 info lifecycle @chrisdopuch/typescript-typings-test@0.0.5~postpack: @chrisdopuch/typescript-typings-test@0.0.5
11 notice
12 notice 📦  @chrisdopuch/typescript-typings-test@0.0.5
13 notice === Tarball Contents ===
14 notice 591B  package.json
14 notice 5.9kB jest.config.js
14 notice 26B   README.md
14 notice 5.3kB tsconfig.json
14 notice 194B  tslint.json
14 notice 40B   .vscode/settings.json
14 notice 11B   dist/__tests__/index.test.d.ts
14 notice 583B  dist/__tests__/index.test.js
14 notice 53B   dist/index.d.ts
14 notice 204B  dist/index.js
15 notice === Tarball Details ===
16 notice name:          @chrisdopuch/typescript-typings-test
16 notice version:       0.0.5
16 notice package size:  4.7 kB
16 notice unpacked size: 12.9 kB
16 notice shasum:        a30e295c7690632431110f114106746d5d9f3f84
16 notice integrity:     sha512-afO/D9YWgBKah[...]X6uOMRA1HvtaQ==
16 notice total files:   10
17 notice
18 verbose getPublishConfig undefined
19 silly mapToRegistry name @chrisdopuch/typescript-typings-test
20 silly mapToRegistry scope (from package name) @chrisdopuch
21 verbose mapToRegistry no registry URL found in name for scope @chrisdopuch
22 silly mapToRegistry using default registry
23 silly mapToRegistry registry https://registry.npmjs.org/
24 silly mapToRegistry data { type: 'tag',
24 silly mapToRegistry   registry: true,
24 silly mapToRegistry   where: undefined,
24 silly mapToRegistry   raw: '@chrisdopuch/typescript-typings-test',
24 silly mapToRegistry   name: '@chrisdopuch/typescript-typings-test',
24 silly mapToRegistry   escapedName: '@chrisdopuch%2ftypescript-typings-test',
24 silly mapToRegistry   scope: '@chrisdopuch',
24 silly mapToRegistry   rawSpec: '',
24 silly mapToRegistry   saveSpec: null,
24 silly mapToRegistry   fetchSpec: 'latest',
24 silly mapToRegistry   gitRange: undefined,
24 silly mapToRegistry   gitCommittish: undefined,
24 silly mapToRegistry   hosted: undefined }
25 silly mapToRegistry uri https://registry.npmjs.org/@chrisdopuch%2ftypescript-typings-test
26 verbose publish registryBase https://registry.npmjs.org/
27 silly publish uploading /tmp/npm-6191-6988acb6/tmp/fromDir-5087b9a2/package.tgz
28 verbose request uri https://registry.npmjs.org/@chrisdopuch%2ftypescript-typings-test
29 verbose request sending authorization for write operation
30 info attempt registry request try #1 at 8:15:46 PM
31 verbose request using bearer token for auth
32 verbose request id a0824cecee7e589b
33 http request PUT https://registry.npmjs.org/@chrisdopuch%2ftypescript-typings-test
34 http 403 https://registry.npmjs.org/@chrisdopuch%2ftypescript-typings-test
35 verbose headers { date: 'Tue, 23 Oct 2018 04:15:50 GMT',
35 verbose headers   'content-type': 'application/json',
35 verbose headers   'transfer-encoding': 'chunked',
35 verbose headers   connection: 'keep-alive',
35 verbose headers   'set-cookie':
35 verbose headers    [ '__cfduid=d37911b52d5e05db7444507c1d79d847c1540268149; expires=Wed, 23-Oct-19 04:15:49 GMT; path=/; domain=.registry.npmjs.org; HttpOnly' ],
35 verbose headers   'cf-ray': '46e1628129888cf9-PDX',
35 verbose headers   'expect-ct':
35 verbose headers    'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
35 verbose headers   vary: 'Accept-Encoding',
35 verbose headers   server: 'cloudflare',
35 verbose headers   'content-encoding': 'gzip' }
36 error publish Failed PUT 403
37 verbose stack Error: You cannot publish over the previously published versions: 0.0.5. : @chrisdopuch/typescript-typings-test
37 verbose stack     at makeError (/home/cdopuch/.nvm/versions/node/v10.7.0/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:329:12)
37 verbose stack     at RegClient.<anonymous> (/home/cdopuch/.nvm/versions/node/v10.7.0/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:317:14)
37 verbose stack     at Gunzip.cb (/home/cdopuch/.nvm/versions/node/v10.7.0/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:222:7)
37 verbose stack     at Gunzip.zlibBufferOnEnd (zlib.js:122:10)
37 verbose stack     at Gunzip.emit (events.js:187:15)
37 verbose stack     at endReadableNT (_stream_readable.js:1081:12)
37 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
38 verbose statusCode 403
39 verbose pkgid @chrisdopuch/typescript-typings-test
40 verbose cwd /mnt/c/app-projects/typescript-typings-test
41 verbose Linux 4.4.0-17134-Microsoft
42 verbose argv "/home/cdopuch/.nvm/versions/node/v10.7.0/bin/node" "/home/cdopuch/.nvm/versions/node/v10.7.0/bin/npm" "publish" "--access" "public" "--verbose"
43 verbose node v10.7.0
44 verbose npm  v6.4.1
45 error code E403
46 error You cannot publish over the previously published versions: 0.0.5. : @chrisdopuch/typescript-typings-test
47 verbose exit [ 1, true ]

Platform Info

$ npm --versions
<!-- paste output here -->
```npm --versions
{ '@chrisdopuch/typescript-typings-test': '0.0.5',
  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.32.0',
  node: '10.7.0',
  openssl: '1.1.0h',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.22.0',
  v8: '6.7.288.49-node.15',
  zlib: '1.2.11' }```
$ `node -p process.platform`
linux
<!-- paste output here -->

(Lars Willighagen) #2

Maybe related to this incident:

Does it work now?


(Chris Dopuch) #3

Good idea, but I don’t think that was it. It’s marked as resolved now, but when I try today I am still getting the 403 error.

npm notice
npm notice 📦  @chrisdopuch/typescript-typings-test@0.0.5
npm notice === Tarball Contents ===
npm notice 591B  package.json
npm notice 5.9kB jest.config.js
npm notice 26B   README.md
npm notice 5.3kB tsconfig.json
npm notice 194B  tslint.json
npm notice 40B   .vscode/settings.json
npm notice 11B   dist/__tests__/index.test.d.ts
npm notice 583B  dist/__tests__/index.test.js
npm notice 53B   dist/index.d.ts
npm notice 204B  dist/index.js
npm notice === Tarball Details ===
npm notice name:          @chrisdopuch/typescript-typings-test
npm notice version:       0.0.5
npm notice package size:  4.7 kB
npm notice unpacked size: 12.9 kB
npm notice shasum:        a30e295c7690632431110f114106746d5d9f3f84
npm notice integrity:     sha512-afO/D9YWgBKah[...]X6uOMRA1HvtaQ==
npm notice total files:   10
npm notice
npm ERR! publish Failed PUT 403
npm ERR! code E403
npm ERR! You cannot publish over the previously published versions: 0.0.5. : @chrisdopuch/typescript-typings-test

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/cdopuch/.npm/_logs/2018-10-24T03_23_05_543Z-debug.log```

(Lars Willighagen) #4

The package seems available on the site to me, but I’m on mobile so I can’t try installing it right now.


(Kat Marchán) #5

https://registry.npmjs.org/@chrisdopuch/typescript-typings-test

0.0.5 is definitely there.


(Chris Dopuch) #6

Interesting, thanks for looking. I’m not quite sure how 5 ended up there, but after investigating a few more versions I think I found the problem on my end.
I believe the root cause was in my package.json scripts:

   "scripts": {
     "build": "tsc",
     "lint": "tslint --project tsconfig.json",
     "publish": "npm publish --access public", // this was being triggered by running `npm publish`
     "test": "jest"
   },

It appears running npm publish in my terminal causes both a normal npm publish to occur as well as running my npm publish script. This would cause the second publish command to fail since the version was already published by the first invocation. You can see that this is happening because of the duplicated output in my terminal:

npm publish
npm notice
npm notice 📦  @chrisdopuch/typescript-typings-test@0.0.7
npm notice === Tarball Contents ===
npm notice 591B  package.json
npm notice 5.9kB jest.config.js
npm notice 26B   README.md
npm notice 5.3kB tsconfig.json
npm notice 194B  tslint.json
npm notice 40B   .vscode/settings.json
npm notice 11B   dist/__tests__/index.test.d.ts
npm notice 583B  dist/__tests__/index.test.js
npm notice 53B   dist/index.d.ts
npm notice 204B  dist/index.js
npm notice === Tarball Details ===
npm notice name:          @chrisdopuch/typescript-typings-test
npm notice version:       0.0.7
npm notice package size:  4.7 kB
npm notice unpacked size: 12.9 kB
npm notice shasum:        5be6d16d268a5c63a1ad3e64924c25772188bc24
npm notice integrity:     sha512-EUI5V01kJSqRG[...]oOUEh6YQBpRbA==
npm notice total files:   10
npm notice

> @chrisdopuch/typescript-typings-test@0.0.7 publish .
> npm publish --access public

npm notice
npm notice 📦  @chrisdopuch/typescript-typings-test@0.0.7
npm notice === Tarball Contents ===
npm notice 591B  package.json
npm notice 5.9kB jest.config.js
npm notice 26B   README.md
npm notice 5.3kB tsconfig.json
npm notice 194B  tslint.json
npm notice 40B   .vscode/settings.json
npm notice 11B   dist/__tests__/index.test.d.ts
npm notice 583B  dist/__tests__/index.test.js
npm notice 53B   dist/index.d.ts
npm notice 204B  dist/index.js
npm notice === Tarball Details ===
npm notice name:          @chrisdopuch/typescript-typings-test
npm notice version:       0.0.7
npm notice package size:  4.7 kB
npm notice unpacked size: 12.9 kB
npm notice shasum:        5be6d16d268a5c63a1ad3e64924c25772188bc24
npm notice integrity:     sha512-EUI5V01kJSqRG[...]oOUEh6YQBpRbA==
npm notice total files:   10
npm notice
npm ERR! publish Failed PUT 403
npm ERR! code E403
npm ERR! You cannot publish over the previously published versions: 0.0.7. : @chrisdopuch/typescript-typings-test

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/cdopuch/.npm/_logs/2018-10-25T06_40_31_956Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @chrisdopuch/typescript-typings-test@0.0.7 publish: `npm publish --access public`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @chrisdopuch/typescript-typings-test@0.0.7 publish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/cdopuch/.npm/_logs/2018-10-25T06_40_32_007Z-debug.log

I now see that in the docs, publish is a keyword that will be triggered after running your publish command. Whoops! Thanks anyways for helping folks, looks like this mystery is solved.
https://docs.npmjs.com/misc/scripts