yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

"Couldn't publish package" #2717

Open jamiewinder opened 7 years ago

jamiewinder commented 7 years ago

Using yarn 0.20.3 on Windows, I'm publishing my module using yarn publish..

$ yarn publish
yarn publish v0.20.3
[1/4] Bumping version...
*info* Current version: 0.1.10
question New version: 0.1.11
info New version: 0.1.11
[2/4] Logging in...
[3/4] Publishing...
error Couldn't publish package.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.

It does publish something, but it seems to be an incomplete package. I have the following in my package.json:

  "files": [
    "dist",
    "CHANGELOG.md",
    "README.md"
  ],

And indeed it seems to publish them, but dist - a directory - is empty. It looks like the contents is being ignored, and the publish fails as a result?

patrickkeller commented 7 years ago

I have exactly the same issue under Ubuntu/Linux. yarn v0.21.3

johngeorgewright commented 7 years ago

I get the error, but everything seems to have been published successfully.

OSX 10.11.6 yarn v0.24.5

antonellil commented 7 years ago

Same here, fails with a 201 error

bchoddny commented 7 years ago

Getting the same error. verbose 5.4 Performing "PUT" request to . verbose 5.641 Request finished with status code 502. verbose 5.644 Error: Couldn't publish package. at MessageError (/Users/testuser/.nvm/versions/node/v6.9.4/lib/node_modules/yarn/lib/errors.js:8:5) at /Users/testuser/.nvm/versions/node/v6.9.4/lib/node_modules/yarn/lib/cli/commands/publish.js:96:13 at next (native) at step (/Users/testuser/.nvm/versions/node/v6.9.4/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30) at /Users/testuser/.nvm/versions/node/v6.9.4/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13 at process._tickCallback (internal/process/next_tick.js:103:7)

viceice commented 7 years ago

Getting status 201 and error with Proget as npm registry. Have to use npm to publish as workaround.

verbose 2.937 Performing "PUT" request to "https://xxx.visualon.de/npm/vo-npm/@types%2fvo-app-base".
verbose 3.442 Request "https://xxx.visualon.de/npm/vo-npm/@types%2fvo-app-base" finished with status code 201.
verbose 3.449 Error: Couldn't publish package.
    at C:\Program Files (x86)\Yarn\lib\yarn-cli.js:77664:13
    at Generator.next (<anonymous>)
    at step (C:\Program Files (x86)\Yarn\lib\yarn-cli.js:91:30)
    at C:\Program Files (x86)\Yarn\lib\yarn-cli.js:102:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
error Couldn't publish package.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
Warning:  Use --force to continue.
cdauth commented 6 years ago

Same issue here, also receiving status code 201 and then the error, but the package gets published anyways.

Ivan-L commented 6 years ago

Same here, but with status code 202 (accepted) using TFS as an NPM registry.

verbose 0.758 Performing "PUT" request to "http://<redacted>".
verbose 1.164 Request "http://<redacted>" finished with status code 202.
verbose 1.18 Error: Couldn't publish package.
    at MessageError (/usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:139:5)
    at /usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:82746:13
    at next (native)
    at step (/usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:92:30)
    at /usr/local/Cellar/yarn/1.3.2/libexec/lib/cli.js:103:13
    at process._tickCallback (internal/process/next_tick.js:103:7)
error Couldn't publish package.
brettpostin commented 6 years ago

MyGet returns 201 causing yarn publish to fail despite the package being successfully published.

jacobfike commented 6 years ago

I am still seeing this issue with yarn 1.3.2.

oligot commented 6 years ago

Same problem here, using Nexus as npm registry.

Running yarn publish --verbose results in the following output

verbose 0.352 Performing "PUT" request to "http://nexus.../content/repositories/npm-internal/oli-playground".  
verbose 0.386 Request "http://nexus.../content/repositories/npm-internal/oli-playground" finished with status code 201.                                                             
res undefined                                                                                                                                                                                  
verbose 0.387 Error: Couldn't publish package.   

The PUT request returns a 201 status code but the body is empty (I logged the response in the above output and it's undefined). Shouldn't yarn check the status instead of the body to determine if the request is successful ?

mkosieradzki commented 6 years ago

@BYK I have created a PR for this issue. Either this fix is trivial like in my PR, or I am missing something (for example compatibility with classic NPM repo).

brendan-hurley commented 6 years ago

Nexus here, fails as above, i.e.

Error: Couldn't publish package.

It hasn't gone ahead and published it despite the error. Using workspaces + lerna, I've basically had to switch to npm as the lerna client just for the publish step... not sure how else to fix this.

medihack commented 6 years ago

Same problem here under Ubuntu 16.04 and Yarn 1.6.0. It even doesn't create an error log to say what's exactly wrong. It just finishes with Error: Couldn't publish package. Time for npm again :-(

nevir commented 6 years ago

Looks like this is happening in Circle CI's environment, too: https://circleci.com/gh/convoyinc/graphql-client-benchmarks/19

lostintime commented 6 years ago

@brendan-hurley @medihack I just had the same issue and looks like yarn publish not respecting publishConfig in package.json.

When used with lerna - setting explicit --registry argument fixed the issue, ex: lerna publish --registry http://your.repo.host/repository/npm-private/.

Also, if you're publishing namespaced packages - you may add namespace configuration to .npmrc (which is used by yarn):

@mycustomns:registry=http://your.repo.host/repository/npm-private/

Both variants did work on a Jenkins server. Hopefully this may help you.

pablorsk commented 6 years ago

Maybe, your problem is not :cat2: Yarn, it's NPM service. These days NPM are invalidating tokens for a received attack.

$ npm publish
npm WARN notice Due to a recent security incident, all user tokens have been invalidated. Please see https://status.npmjs.org/incidents/dn7c1fgrr7ng for more details. To generate a new token, visit https://www.npmjs.com/settings/~/tokens or run "npm login".
npm ERR! publish Failed PUT 403
npm ERR! code E403

$ yarn publish
yarn publish v1.6.0
...
error Couldn't publish package.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
greena13 commented 6 years ago

I was getting this because I had enabled two factor authentication after the npm security incident. Running npm publish gave me an additional prompt to enter the 2FA code.

It seems yarn doesn't support this yet. More info can be found at https://github.com/yarnpkg/yarn/issues/4904

viceice commented 4 years ago

Now we get the following on renovatebot image

Package published but yarn failed with ESOCKETTIMEDOUT

softmarshmallow commented 3 years ago

What's causing this?

fedeghe commented 2 years ago

same problem ...I tried again adding the access param ...and worked yarn publish --access=public